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    #[deprecated = "Strict unions should not use `is_unknown`"]
214    #[inline]
215    pub fn is_unknown(&self) -> bool {
216        false
217    }
218}
219
220impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InputType {}
221
222#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
223pub struct VirtioBalloonMarker;
224
225impl fidl::endpoints::ProtocolMarker for VirtioBalloonMarker {
226    type Proxy = VirtioBalloonProxy;
227    type RequestStream = VirtioBalloonRequestStream;
228    #[cfg(target_os = "fuchsia")]
229    type SynchronousProxy = VirtioBalloonSynchronousProxy;
230
231    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioBalloon";
232}
233impl fidl::endpoints::DiscoverableProtocolMarker for VirtioBalloonMarker {}
234
235pub trait VirtioBalloonProxyInterface: Send + Sync {
236    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
237    fn r#configure_queue(
238        &self,
239        queue: u16,
240        size: u16,
241        desc: u64,
242        avail: u64,
243        used: u64,
244    ) -> Self::ConfigureQueueResponseFut;
245    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
246    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
247    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
248    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
249    fn r#start(&self, start_info: StartInfo) -> Self::StartResponseFut;
250    type GetMemStatsResponseFut: std::future::Future<
251            Output = Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error>,
252        > + Send;
253    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut;
254}
255#[derive(Debug)]
256#[cfg(target_os = "fuchsia")]
257pub struct VirtioBalloonSynchronousProxy {
258    client: fidl::client::sync::Client,
259}
260
261#[cfg(target_os = "fuchsia")]
262impl fidl::endpoints::SynchronousProxy for VirtioBalloonSynchronousProxy {
263    type Proxy = VirtioBalloonProxy;
264    type Protocol = VirtioBalloonMarker;
265
266    fn from_channel(inner: fidl::Channel) -> Self {
267        Self::new(inner)
268    }
269
270    fn into_channel(self) -> fidl::Channel {
271        self.client.into_channel()
272    }
273
274    fn as_channel(&self) -> &fidl::Channel {
275        self.client.as_channel()
276    }
277}
278
279#[cfg(target_os = "fuchsia")]
280impl VirtioBalloonSynchronousProxy {
281    pub fn new(channel: fidl::Channel) -> Self {
282        let protocol_name = <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
283        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
284    }
285
286    pub fn into_channel(self) -> fidl::Channel {
287        self.client.into_channel()
288    }
289
290    /// Waits until an event arrives and returns it. It is safe for other
291    /// threads to make concurrent requests while waiting for an event.
292    pub fn wait_for_event(
293        &self,
294        deadline: zx::MonotonicInstant,
295    ) -> Result<VirtioBalloonEvent, fidl::Error> {
296        VirtioBalloonEvent::decode(self.client.wait_for_event(deadline)?)
297    }
298
299    /// Configure a `queue` for the device. This specifies the `size` and the
300    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
301    pub fn r#configure_queue(
302        &self,
303        mut queue: u16,
304        mut size: u16,
305        mut desc: u64,
306        mut avail: u64,
307        mut used: u64,
308        ___deadline: zx::MonotonicInstant,
309    ) -> Result<(), fidl::Error> {
310        let _response = self
311            .client
312            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
313                (queue, size, desc, avail, used),
314                0x72b44fb963480b11,
315                fidl::encoding::DynamicFlags::empty(),
316                ___deadline,
317            )?;
318        Ok(_response)
319    }
320
321    /// Notify a `queue` for the device. Primarily used for black-box testing.
322    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
323        self.client.send::<VirtioDeviceNotifyQueueRequest>(
324            (queue,),
325            0x6e3a61d652499244,
326            fidl::encoding::DynamicFlags::empty(),
327        )
328    }
329
330    /// Ready a device. This provides the set of `negotiated_features` that the
331    /// driver and device have agreed upon.
332    pub fn r#ready(
333        &self,
334        mut negotiated_features: u32,
335        ___deadline: zx::MonotonicInstant,
336    ) -> Result<(), fidl::Error> {
337        let _response =
338            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
339                (negotiated_features,),
340                0x45707654f5d23c3f,
341                fidl::encoding::DynamicFlags::empty(),
342                ___deadline,
343            )?;
344        Ok(_response)
345    }
346
347    /// Start the balloon device.
348    pub fn r#start(
349        &self,
350        mut start_info: StartInfo,
351        ___deadline: zx::MonotonicInstant,
352    ) -> Result<(), fidl::Error> {
353        let _response =
354            self.client.send_query::<VirtioBalloonStartRequest, fidl::encoding::EmptyPayload>(
355                (&mut start_info,),
356                0x26645282fddf6f46,
357                fidl::encoding::DynamicFlags::empty(),
358                ___deadline,
359            )?;
360        Ok(_response)
361    }
362
363    /// Get memory statistics from the balloon device.
364    pub fn r#get_mem_stats(
365        &self,
366        ___deadline: zx::MonotonicInstant,
367    ) -> Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error> {
368        let _response = self
369            .client
370            .send_query::<fidl::encoding::EmptyPayload, VirtioBalloonGetMemStatsResponse>(
371                (),
372                0x6641f4c296607e24,
373                fidl::encoding::DynamicFlags::empty(),
374                ___deadline,
375            )?;
376        Ok((_response.status, _response.mem_stats))
377    }
378}
379
380#[cfg(target_os = "fuchsia")]
381impl From<VirtioBalloonSynchronousProxy> for zx::Handle {
382    fn from(value: VirtioBalloonSynchronousProxy) -> Self {
383        value.into_channel().into()
384    }
385}
386
387#[cfg(target_os = "fuchsia")]
388impl From<fidl::Channel> for VirtioBalloonSynchronousProxy {
389    fn from(value: fidl::Channel) -> Self {
390        Self::new(value)
391    }
392}
393
394#[derive(Debug, Clone)]
395pub struct VirtioBalloonProxy {
396    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
397}
398
399impl fidl::endpoints::Proxy for VirtioBalloonProxy {
400    type Protocol = VirtioBalloonMarker;
401
402    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
403        Self::new(inner)
404    }
405
406    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
407        self.client.into_channel().map_err(|client| Self { client })
408    }
409
410    fn as_channel(&self) -> &::fidl::AsyncChannel {
411        self.client.as_channel()
412    }
413}
414
415impl VirtioBalloonProxy {
416    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioBalloon.
417    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
418        let protocol_name = <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
419        Self { client: fidl::client::Client::new(channel, protocol_name) }
420    }
421
422    /// Get a Stream of events from the remote end of the protocol.
423    ///
424    /// # Panics
425    ///
426    /// Panics if the event stream was already taken.
427    pub fn take_event_stream(&self) -> VirtioBalloonEventStream {
428        VirtioBalloonEventStream { event_receiver: self.client.take_event_receiver() }
429    }
430
431    /// Configure a `queue` for the device. This specifies the `size` and the
432    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
433    pub fn r#configure_queue(
434        &self,
435        mut queue: u16,
436        mut size: u16,
437        mut desc: u64,
438        mut avail: u64,
439        mut used: u64,
440    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
441        VirtioBalloonProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
442    }
443
444    /// Notify a `queue` for the device. Primarily used for black-box testing.
445    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
446        VirtioBalloonProxyInterface::r#notify_queue(self, queue)
447    }
448
449    /// Ready a device. This provides the set of `negotiated_features` that the
450    /// driver and device have agreed upon.
451    pub fn r#ready(
452        &self,
453        mut negotiated_features: u32,
454    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
455        VirtioBalloonProxyInterface::r#ready(self, negotiated_features)
456    }
457
458    /// Start the balloon device.
459    pub fn r#start(
460        &self,
461        mut start_info: StartInfo,
462    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
463        VirtioBalloonProxyInterface::r#start(self, start_info)
464    }
465
466    /// Get memory statistics from the balloon device.
467    pub fn r#get_mem_stats(
468        &self,
469    ) -> fidl::client::QueryResponseFut<
470        (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
471        fidl::encoding::DefaultFuchsiaResourceDialect,
472    > {
473        VirtioBalloonProxyInterface::r#get_mem_stats(self)
474    }
475}
476
477impl VirtioBalloonProxyInterface for VirtioBalloonProxy {
478    type ConfigureQueueResponseFut =
479        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
480    fn r#configure_queue(
481        &self,
482        mut queue: u16,
483        mut size: u16,
484        mut desc: u64,
485        mut avail: u64,
486        mut used: u64,
487    ) -> Self::ConfigureQueueResponseFut {
488        fn _decode(
489            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
490        ) -> Result<(), fidl::Error> {
491            let _response = fidl::client::decode_transaction_body::<
492                fidl::encoding::EmptyPayload,
493                fidl::encoding::DefaultFuchsiaResourceDialect,
494                0x72b44fb963480b11,
495            >(_buf?)?;
496            Ok(_response)
497        }
498        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
499            (queue, size, desc, avail, used),
500            0x72b44fb963480b11,
501            fidl::encoding::DynamicFlags::empty(),
502            _decode,
503        )
504    }
505
506    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
507        self.client.send::<VirtioDeviceNotifyQueueRequest>(
508            (queue,),
509            0x6e3a61d652499244,
510            fidl::encoding::DynamicFlags::empty(),
511        )
512    }
513
514    type ReadyResponseFut =
515        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
516    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
517        fn _decode(
518            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
519        ) -> Result<(), fidl::Error> {
520            let _response = fidl::client::decode_transaction_body::<
521                fidl::encoding::EmptyPayload,
522                fidl::encoding::DefaultFuchsiaResourceDialect,
523                0x45707654f5d23c3f,
524            >(_buf?)?;
525            Ok(_response)
526        }
527        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
528            (negotiated_features,),
529            0x45707654f5d23c3f,
530            fidl::encoding::DynamicFlags::empty(),
531            _decode,
532        )
533    }
534
535    type StartResponseFut =
536        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
537    fn r#start(&self, mut start_info: StartInfo) -> Self::StartResponseFut {
538        fn _decode(
539            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
540        ) -> Result<(), fidl::Error> {
541            let _response = fidl::client::decode_transaction_body::<
542                fidl::encoding::EmptyPayload,
543                fidl::encoding::DefaultFuchsiaResourceDialect,
544                0x26645282fddf6f46,
545            >(_buf?)?;
546            Ok(_response)
547        }
548        self.client.send_query_and_decode::<VirtioBalloonStartRequest, ()>(
549            (&mut start_info,),
550            0x26645282fddf6f46,
551            fidl::encoding::DynamicFlags::empty(),
552            _decode,
553        )
554    }
555
556    type GetMemStatsResponseFut = fidl::client::QueryResponseFut<
557        (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
558        fidl::encoding::DefaultFuchsiaResourceDialect,
559    >;
560    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut {
561        fn _decode(
562            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
563        ) -> Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error> {
564            let _response = fidl::client::decode_transaction_body::<
565                VirtioBalloonGetMemStatsResponse,
566                fidl::encoding::DefaultFuchsiaResourceDialect,
567                0x6641f4c296607e24,
568            >(_buf?)?;
569            Ok((_response.status, _response.mem_stats))
570        }
571        self.client.send_query_and_decode::<
572            fidl::encoding::EmptyPayload,
573            (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
574        >(
575            (),
576            0x6641f4c296607e24,
577            fidl::encoding::DynamicFlags::empty(),
578            _decode,
579        )
580    }
581}
582
583pub struct VirtioBalloonEventStream {
584    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
585}
586
587impl std::marker::Unpin for VirtioBalloonEventStream {}
588
589impl futures::stream::FusedStream for VirtioBalloonEventStream {
590    fn is_terminated(&self) -> bool {
591        self.event_receiver.is_terminated()
592    }
593}
594
595impl futures::Stream for VirtioBalloonEventStream {
596    type Item = Result<VirtioBalloonEvent, fidl::Error>;
597
598    fn poll_next(
599        mut self: std::pin::Pin<&mut Self>,
600        cx: &mut std::task::Context<'_>,
601    ) -> std::task::Poll<Option<Self::Item>> {
602        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
603            &mut self.event_receiver,
604            cx
605        )?) {
606            Some(buf) => std::task::Poll::Ready(Some(VirtioBalloonEvent::decode(buf))),
607            None => std::task::Poll::Ready(None),
608        }
609    }
610}
611
612#[derive(Debug)]
613pub enum VirtioBalloonEvent {}
614
615impl VirtioBalloonEvent {
616    /// Decodes a message buffer as a [`VirtioBalloonEvent`].
617    fn decode(
618        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
619    ) -> Result<VirtioBalloonEvent, fidl::Error> {
620        let (bytes, _handles) = buf.split_mut();
621        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
622        debug_assert_eq!(tx_header.tx_id, 0);
623        match tx_header.ordinal {
624            _ => Err(fidl::Error::UnknownOrdinal {
625                ordinal: tx_header.ordinal,
626                protocol_name: <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
627            }),
628        }
629    }
630}
631
632/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioBalloon.
633pub struct VirtioBalloonRequestStream {
634    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
635    is_terminated: bool,
636}
637
638impl std::marker::Unpin for VirtioBalloonRequestStream {}
639
640impl futures::stream::FusedStream for VirtioBalloonRequestStream {
641    fn is_terminated(&self) -> bool {
642        self.is_terminated
643    }
644}
645
646impl fidl::endpoints::RequestStream for VirtioBalloonRequestStream {
647    type Protocol = VirtioBalloonMarker;
648    type ControlHandle = VirtioBalloonControlHandle;
649
650    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
651        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
652    }
653
654    fn control_handle(&self) -> Self::ControlHandle {
655        VirtioBalloonControlHandle { inner: self.inner.clone() }
656    }
657
658    fn into_inner(
659        self,
660    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
661    {
662        (self.inner, self.is_terminated)
663    }
664
665    fn from_inner(
666        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
667        is_terminated: bool,
668    ) -> Self {
669        Self { inner, is_terminated }
670    }
671}
672
673impl futures::Stream for VirtioBalloonRequestStream {
674    type Item = Result<VirtioBalloonRequest, fidl::Error>;
675
676    fn poll_next(
677        mut self: std::pin::Pin<&mut Self>,
678        cx: &mut std::task::Context<'_>,
679    ) -> std::task::Poll<Option<Self::Item>> {
680        let this = &mut *self;
681        if this.inner.check_shutdown(cx) {
682            this.is_terminated = true;
683            return std::task::Poll::Ready(None);
684        }
685        if this.is_terminated {
686            panic!("polled VirtioBalloonRequestStream after completion");
687        }
688        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
689            |bytes, handles| {
690                match this.inner.channel().read_etc(cx, bytes, handles) {
691                    std::task::Poll::Ready(Ok(())) => {}
692                    std::task::Poll::Pending => return std::task::Poll::Pending,
693                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
694                        this.is_terminated = true;
695                        return std::task::Poll::Ready(None);
696                    }
697                    std::task::Poll::Ready(Err(e)) => {
698                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
699                            e.into(),
700                        ))))
701                    }
702                }
703
704                // A message has been received from the channel
705                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
706
707                std::task::Poll::Ready(Some(match header.ordinal {
708                    0x72b44fb963480b11 => {
709                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
710                        let mut req = fidl::new_empty!(
711                            VirtioDeviceConfigureQueueRequest,
712                            fidl::encoding::DefaultFuchsiaResourceDialect
713                        );
714                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
715                        let control_handle =
716                            VirtioBalloonControlHandle { inner: this.inner.clone() };
717                        Ok(VirtioBalloonRequest::ConfigureQueue {
718                            queue: req.queue,
719                            size: req.size,
720                            desc: req.desc,
721                            avail: req.avail,
722                            used: req.used,
723
724                            responder: VirtioBalloonConfigureQueueResponder {
725                                control_handle: std::mem::ManuallyDrop::new(control_handle),
726                                tx_id: header.tx_id,
727                            },
728                        })
729                    }
730                    0x6e3a61d652499244 => {
731                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
732                        let mut req = fidl::new_empty!(
733                            VirtioDeviceNotifyQueueRequest,
734                            fidl::encoding::DefaultFuchsiaResourceDialect
735                        );
736                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
737                        let control_handle =
738                            VirtioBalloonControlHandle { inner: this.inner.clone() };
739                        Ok(VirtioBalloonRequest::NotifyQueue { queue: req.queue, control_handle })
740                    }
741                    0x45707654f5d23c3f => {
742                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
743                        let mut req = fidl::new_empty!(
744                            VirtioDeviceReadyRequest,
745                            fidl::encoding::DefaultFuchsiaResourceDialect
746                        );
747                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
748                        let control_handle =
749                            VirtioBalloonControlHandle { inner: this.inner.clone() };
750                        Ok(VirtioBalloonRequest::Ready {
751                            negotiated_features: req.negotiated_features,
752
753                            responder: VirtioBalloonReadyResponder {
754                                control_handle: std::mem::ManuallyDrop::new(control_handle),
755                                tx_id: header.tx_id,
756                            },
757                        })
758                    }
759                    0x26645282fddf6f46 => {
760                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
761                        let mut req = fidl::new_empty!(
762                            VirtioBalloonStartRequest,
763                            fidl::encoding::DefaultFuchsiaResourceDialect
764                        );
765                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioBalloonStartRequest>(&header, _body_bytes, handles, &mut req)?;
766                        let control_handle =
767                            VirtioBalloonControlHandle { inner: this.inner.clone() };
768                        Ok(VirtioBalloonRequest::Start {
769                            start_info: req.start_info,
770
771                            responder: VirtioBalloonStartResponder {
772                                control_handle: std::mem::ManuallyDrop::new(control_handle),
773                                tx_id: header.tx_id,
774                            },
775                        })
776                    }
777                    0x6641f4c296607e24 => {
778                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
779                        let mut req = fidl::new_empty!(
780                            fidl::encoding::EmptyPayload,
781                            fidl::encoding::DefaultFuchsiaResourceDialect
782                        );
783                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
784                        let control_handle =
785                            VirtioBalloonControlHandle { inner: this.inner.clone() };
786                        Ok(VirtioBalloonRequest::GetMemStats {
787                            responder: VirtioBalloonGetMemStatsResponder {
788                                control_handle: std::mem::ManuallyDrop::new(control_handle),
789                                tx_id: header.tx_id,
790                            },
791                        })
792                    }
793                    _ => Err(fidl::Error::UnknownOrdinal {
794                        ordinal: header.ordinal,
795                        protocol_name:
796                            <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
797                    }),
798                }))
799            },
800        )
801    }
802}
803
804#[derive(Debug)]
805pub enum VirtioBalloonRequest {
806    /// Configure a `queue` for the device. This specifies the `size` and the
807    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
808    ConfigureQueue {
809        queue: u16,
810        size: u16,
811        desc: u64,
812        avail: u64,
813        used: u64,
814        responder: VirtioBalloonConfigureQueueResponder,
815    },
816    /// Notify a `queue` for the device. Primarily used for black-box testing.
817    NotifyQueue { queue: u16, control_handle: VirtioBalloonControlHandle },
818    /// Ready a device. This provides the set of `negotiated_features` that the
819    /// driver and device have agreed upon.
820    Ready { negotiated_features: u32, responder: VirtioBalloonReadyResponder },
821    /// Start the balloon device.
822    Start { start_info: StartInfo, responder: VirtioBalloonStartResponder },
823    /// Get memory statistics from the balloon device.
824    GetMemStats { responder: VirtioBalloonGetMemStatsResponder },
825}
826
827impl VirtioBalloonRequest {
828    #[allow(irrefutable_let_patterns)]
829    pub fn into_configure_queue(
830        self,
831    ) -> Option<(u16, u16, u64, u64, u64, VirtioBalloonConfigureQueueResponder)> {
832        if let VirtioBalloonRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
833            self
834        {
835            Some((queue, size, desc, avail, used, responder))
836        } else {
837            None
838        }
839    }
840
841    #[allow(irrefutable_let_patterns)]
842    pub fn into_notify_queue(self) -> Option<(u16, VirtioBalloonControlHandle)> {
843        if let VirtioBalloonRequest::NotifyQueue { queue, control_handle } = self {
844            Some((queue, control_handle))
845        } else {
846            None
847        }
848    }
849
850    #[allow(irrefutable_let_patterns)]
851    pub fn into_ready(self) -> Option<(u32, VirtioBalloonReadyResponder)> {
852        if let VirtioBalloonRequest::Ready { negotiated_features, responder } = self {
853            Some((negotiated_features, responder))
854        } else {
855            None
856        }
857    }
858
859    #[allow(irrefutable_let_patterns)]
860    pub fn into_start(self) -> Option<(StartInfo, VirtioBalloonStartResponder)> {
861        if let VirtioBalloonRequest::Start { start_info, responder } = self {
862            Some((start_info, responder))
863        } else {
864            None
865        }
866    }
867
868    #[allow(irrefutable_let_patterns)]
869    pub fn into_get_mem_stats(self) -> Option<(VirtioBalloonGetMemStatsResponder)> {
870        if let VirtioBalloonRequest::GetMemStats { responder } = self {
871            Some((responder))
872        } else {
873            None
874        }
875    }
876
877    /// Name of the method defined in FIDL
878    pub fn method_name(&self) -> &'static str {
879        match *self {
880            VirtioBalloonRequest::ConfigureQueue { .. } => "configure_queue",
881            VirtioBalloonRequest::NotifyQueue { .. } => "notify_queue",
882            VirtioBalloonRequest::Ready { .. } => "ready",
883            VirtioBalloonRequest::Start { .. } => "start",
884            VirtioBalloonRequest::GetMemStats { .. } => "get_mem_stats",
885        }
886    }
887}
888
889#[derive(Debug, Clone)]
890pub struct VirtioBalloonControlHandle {
891    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
892}
893
894impl fidl::endpoints::ControlHandle for VirtioBalloonControlHandle {
895    fn shutdown(&self) {
896        self.inner.shutdown()
897    }
898    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
899        self.inner.shutdown_with_epitaph(status)
900    }
901
902    fn is_closed(&self) -> bool {
903        self.inner.channel().is_closed()
904    }
905    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
906        self.inner.channel().on_closed()
907    }
908
909    #[cfg(target_os = "fuchsia")]
910    fn signal_peer(
911        &self,
912        clear_mask: zx::Signals,
913        set_mask: zx::Signals,
914    ) -> Result<(), zx_status::Status> {
915        use fidl::Peered;
916        self.inner.channel().signal_peer(clear_mask, set_mask)
917    }
918}
919
920impl VirtioBalloonControlHandle {}
921
922#[must_use = "FIDL methods require a response to be sent"]
923#[derive(Debug)]
924pub struct VirtioBalloonConfigureQueueResponder {
925    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
926    tx_id: u32,
927}
928
929/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
930/// if the responder is dropped without sending a response, so that the client
931/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
932impl std::ops::Drop for VirtioBalloonConfigureQueueResponder {
933    fn drop(&mut self) {
934        self.control_handle.shutdown();
935        // Safety: drops once, never accessed again
936        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
937    }
938}
939
940impl fidl::endpoints::Responder for VirtioBalloonConfigureQueueResponder {
941    type ControlHandle = VirtioBalloonControlHandle;
942
943    fn control_handle(&self) -> &VirtioBalloonControlHandle {
944        &self.control_handle
945    }
946
947    fn drop_without_shutdown(mut self) {
948        // Safety: drops once, never accessed again due to mem::forget
949        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
950        // Prevent Drop from running (which would shut down the channel)
951        std::mem::forget(self);
952    }
953}
954
955impl VirtioBalloonConfigureQueueResponder {
956    /// Sends a response to the FIDL transaction.
957    ///
958    /// Sets the channel to shutdown if an error occurs.
959    pub fn send(self) -> Result<(), fidl::Error> {
960        let _result = self.send_raw();
961        if _result.is_err() {
962            self.control_handle.shutdown();
963        }
964        self.drop_without_shutdown();
965        _result
966    }
967
968    /// Similar to "send" but does not shutdown the channel if an error occurs.
969    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
970        let _result = self.send_raw();
971        self.drop_without_shutdown();
972        _result
973    }
974
975    fn send_raw(&self) -> Result<(), fidl::Error> {
976        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
977            (),
978            self.tx_id,
979            0x72b44fb963480b11,
980            fidl::encoding::DynamicFlags::empty(),
981        )
982    }
983}
984
985#[must_use = "FIDL methods require a response to be sent"]
986#[derive(Debug)]
987pub struct VirtioBalloonReadyResponder {
988    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
989    tx_id: u32,
990}
991
992/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
993/// if the responder is dropped without sending a response, so that the client
994/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
995impl std::ops::Drop for VirtioBalloonReadyResponder {
996    fn drop(&mut self) {
997        self.control_handle.shutdown();
998        // Safety: drops once, never accessed again
999        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1000    }
1001}
1002
1003impl fidl::endpoints::Responder for VirtioBalloonReadyResponder {
1004    type ControlHandle = VirtioBalloonControlHandle;
1005
1006    fn control_handle(&self) -> &VirtioBalloonControlHandle {
1007        &self.control_handle
1008    }
1009
1010    fn drop_without_shutdown(mut self) {
1011        // Safety: drops once, never accessed again due to mem::forget
1012        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1013        // Prevent Drop from running (which would shut down the channel)
1014        std::mem::forget(self);
1015    }
1016}
1017
1018impl VirtioBalloonReadyResponder {
1019    /// Sends a response to the FIDL transaction.
1020    ///
1021    /// Sets the channel to shutdown if an error occurs.
1022    pub fn send(self) -> Result<(), fidl::Error> {
1023        let _result = self.send_raw();
1024        if _result.is_err() {
1025            self.control_handle.shutdown();
1026        }
1027        self.drop_without_shutdown();
1028        _result
1029    }
1030
1031    /// Similar to "send" but does not shutdown the channel if an error occurs.
1032    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1033        let _result = self.send_raw();
1034        self.drop_without_shutdown();
1035        _result
1036    }
1037
1038    fn send_raw(&self) -> Result<(), fidl::Error> {
1039        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1040            (),
1041            self.tx_id,
1042            0x45707654f5d23c3f,
1043            fidl::encoding::DynamicFlags::empty(),
1044        )
1045    }
1046}
1047
1048#[must_use = "FIDL methods require a response to be sent"]
1049#[derive(Debug)]
1050pub struct VirtioBalloonStartResponder {
1051    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
1052    tx_id: u32,
1053}
1054
1055/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
1056/// if the responder is dropped without sending a response, so that the client
1057/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1058impl std::ops::Drop for VirtioBalloonStartResponder {
1059    fn drop(&mut self) {
1060        self.control_handle.shutdown();
1061        // Safety: drops once, never accessed again
1062        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1063    }
1064}
1065
1066impl fidl::endpoints::Responder for VirtioBalloonStartResponder {
1067    type ControlHandle = VirtioBalloonControlHandle;
1068
1069    fn control_handle(&self) -> &VirtioBalloonControlHandle {
1070        &self.control_handle
1071    }
1072
1073    fn drop_without_shutdown(mut self) {
1074        // Safety: drops once, never accessed again due to mem::forget
1075        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1076        // Prevent Drop from running (which would shut down the channel)
1077        std::mem::forget(self);
1078    }
1079}
1080
1081impl VirtioBalloonStartResponder {
1082    /// Sends a response to the FIDL transaction.
1083    ///
1084    /// Sets the channel to shutdown if an error occurs.
1085    pub fn send(self) -> Result<(), fidl::Error> {
1086        let _result = self.send_raw();
1087        if _result.is_err() {
1088            self.control_handle.shutdown();
1089        }
1090        self.drop_without_shutdown();
1091        _result
1092    }
1093
1094    /// Similar to "send" but does not shutdown the channel if an error occurs.
1095    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1096        let _result = self.send_raw();
1097        self.drop_without_shutdown();
1098        _result
1099    }
1100
1101    fn send_raw(&self) -> Result<(), fidl::Error> {
1102        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1103            (),
1104            self.tx_id,
1105            0x26645282fddf6f46,
1106            fidl::encoding::DynamicFlags::empty(),
1107        )
1108    }
1109}
1110
1111#[must_use = "FIDL methods require a response to be sent"]
1112#[derive(Debug)]
1113pub struct VirtioBalloonGetMemStatsResponder {
1114    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
1115    tx_id: u32,
1116}
1117
1118/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
1119/// if the responder is dropped without sending a response, so that the client
1120/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1121impl std::ops::Drop for VirtioBalloonGetMemStatsResponder {
1122    fn drop(&mut self) {
1123        self.control_handle.shutdown();
1124        // Safety: drops once, never accessed again
1125        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1126    }
1127}
1128
1129impl fidl::endpoints::Responder for VirtioBalloonGetMemStatsResponder {
1130    type ControlHandle = VirtioBalloonControlHandle;
1131
1132    fn control_handle(&self) -> &VirtioBalloonControlHandle {
1133        &self.control_handle
1134    }
1135
1136    fn drop_without_shutdown(mut self) {
1137        // Safety: drops once, never accessed again due to mem::forget
1138        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1139        // Prevent Drop from running (which would shut down the channel)
1140        std::mem::forget(self);
1141    }
1142}
1143
1144impl VirtioBalloonGetMemStatsResponder {
1145    /// Sends a response to the FIDL transaction.
1146    ///
1147    /// Sets the channel to shutdown if an error occurs.
1148    pub fn send(
1149        self,
1150        mut status: i32,
1151        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1152    ) -> Result<(), fidl::Error> {
1153        let _result = self.send_raw(status, mem_stats);
1154        if _result.is_err() {
1155            self.control_handle.shutdown();
1156        }
1157        self.drop_without_shutdown();
1158        _result
1159    }
1160
1161    /// Similar to "send" but does not shutdown the channel if an error occurs.
1162    pub fn send_no_shutdown_on_err(
1163        self,
1164        mut status: i32,
1165        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1166    ) -> Result<(), fidl::Error> {
1167        let _result = self.send_raw(status, mem_stats);
1168        self.drop_without_shutdown();
1169        _result
1170    }
1171
1172    fn send_raw(
1173        &self,
1174        mut status: i32,
1175        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1176    ) -> Result<(), fidl::Error> {
1177        self.control_handle.inner.send::<VirtioBalloonGetMemStatsResponse>(
1178            (status, mem_stats),
1179            self.tx_id,
1180            0x6641f4c296607e24,
1181            fidl::encoding::DynamicFlags::empty(),
1182        )
1183    }
1184}
1185
1186#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1187pub struct VirtioBlockMarker;
1188
1189impl fidl::endpoints::ProtocolMarker for VirtioBlockMarker {
1190    type Proxy = VirtioBlockProxy;
1191    type RequestStream = VirtioBlockRequestStream;
1192    #[cfg(target_os = "fuchsia")]
1193    type SynchronousProxy = VirtioBlockSynchronousProxy;
1194
1195    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioBlock";
1196}
1197impl fidl::endpoints::DiscoverableProtocolMarker for VirtioBlockMarker {}
1198
1199pub trait VirtioBlockProxyInterface: Send + Sync {
1200    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1201    fn r#configure_queue(
1202        &self,
1203        queue: u16,
1204        size: u16,
1205        desc: u64,
1206        avail: u64,
1207        used: u64,
1208    ) -> Self::ConfigureQueueResponseFut;
1209    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
1210    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1211    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
1212    type StartResponseFut: std::future::Future<Output = Result<(u64, u32), fidl::Error>> + Send;
1213    fn r#start(
1214        &self,
1215        start_info: StartInfo,
1216        spec: fidl_fuchsia_virtualization::BlockSpec,
1217    ) -> Self::StartResponseFut;
1218}
1219#[derive(Debug)]
1220#[cfg(target_os = "fuchsia")]
1221pub struct VirtioBlockSynchronousProxy {
1222    client: fidl::client::sync::Client,
1223}
1224
1225#[cfg(target_os = "fuchsia")]
1226impl fidl::endpoints::SynchronousProxy for VirtioBlockSynchronousProxy {
1227    type Proxy = VirtioBlockProxy;
1228    type Protocol = VirtioBlockMarker;
1229
1230    fn from_channel(inner: fidl::Channel) -> Self {
1231        Self::new(inner)
1232    }
1233
1234    fn into_channel(self) -> fidl::Channel {
1235        self.client.into_channel()
1236    }
1237
1238    fn as_channel(&self) -> &fidl::Channel {
1239        self.client.as_channel()
1240    }
1241}
1242
1243#[cfg(target_os = "fuchsia")]
1244impl VirtioBlockSynchronousProxy {
1245    pub fn new(channel: fidl::Channel) -> Self {
1246        let protocol_name = <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1247        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1248    }
1249
1250    pub fn into_channel(self) -> fidl::Channel {
1251        self.client.into_channel()
1252    }
1253
1254    /// Waits until an event arrives and returns it. It is safe for other
1255    /// threads to make concurrent requests while waiting for an event.
1256    pub fn wait_for_event(
1257        &self,
1258        deadline: zx::MonotonicInstant,
1259    ) -> Result<VirtioBlockEvent, fidl::Error> {
1260        VirtioBlockEvent::decode(self.client.wait_for_event(deadline)?)
1261    }
1262
1263    /// Configure a `queue` for the device. This specifies the `size` and the
1264    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1265    pub fn r#configure_queue(
1266        &self,
1267        mut queue: u16,
1268        mut size: u16,
1269        mut desc: u64,
1270        mut avail: u64,
1271        mut used: u64,
1272        ___deadline: zx::MonotonicInstant,
1273    ) -> Result<(), fidl::Error> {
1274        let _response = self
1275            .client
1276            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
1277                (queue, size, desc, avail, used),
1278                0x72b44fb963480b11,
1279                fidl::encoding::DynamicFlags::empty(),
1280                ___deadline,
1281            )?;
1282        Ok(_response)
1283    }
1284
1285    /// Notify a `queue` for the device. Primarily used for black-box testing.
1286    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1287        self.client.send::<VirtioDeviceNotifyQueueRequest>(
1288            (queue,),
1289            0x6e3a61d652499244,
1290            fidl::encoding::DynamicFlags::empty(),
1291        )
1292    }
1293
1294    /// Ready a device. This provides the set of `negotiated_features` that the
1295    /// driver and device have agreed upon.
1296    pub fn r#ready(
1297        &self,
1298        mut negotiated_features: u32,
1299        ___deadline: zx::MonotonicInstant,
1300    ) -> Result<(), fidl::Error> {
1301        let _response =
1302            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
1303                (negotiated_features,),
1304                0x45707654f5d23c3f,
1305                fidl::encoding::DynamicFlags::empty(),
1306                ___deadline,
1307            )?;
1308        Ok(_response)
1309    }
1310
1311    /// Start the block device.
1312    pub fn r#start(
1313        &self,
1314        mut start_info: StartInfo,
1315        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1316        ___deadline: zx::MonotonicInstant,
1317    ) -> Result<(u64, u32), fidl::Error> {
1318        let _response =
1319            self.client.send_query::<VirtioBlockStartRequest, VirtioBlockStartResponse>(
1320                (&mut start_info, &mut spec),
1321                0x5ef6a4b9ce9adcb2,
1322                fidl::encoding::DynamicFlags::empty(),
1323                ___deadline,
1324            )?;
1325        Ok((_response.capacity, _response.block_size))
1326    }
1327}
1328
1329#[cfg(target_os = "fuchsia")]
1330impl From<VirtioBlockSynchronousProxy> for zx::Handle {
1331    fn from(value: VirtioBlockSynchronousProxy) -> Self {
1332        value.into_channel().into()
1333    }
1334}
1335
1336#[cfg(target_os = "fuchsia")]
1337impl From<fidl::Channel> for VirtioBlockSynchronousProxy {
1338    fn from(value: fidl::Channel) -> Self {
1339        Self::new(value)
1340    }
1341}
1342
1343#[derive(Debug, Clone)]
1344pub struct VirtioBlockProxy {
1345    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1346}
1347
1348impl fidl::endpoints::Proxy for VirtioBlockProxy {
1349    type Protocol = VirtioBlockMarker;
1350
1351    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1352        Self::new(inner)
1353    }
1354
1355    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1356        self.client.into_channel().map_err(|client| Self { client })
1357    }
1358
1359    fn as_channel(&self) -> &::fidl::AsyncChannel {
1360        self.client.as_channel()
1361    }
1362}
1363
1364impl VirtioBlockProxy {
1365    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioBlock.
1366    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1367        let protocol_name = <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1368        Self { client: fidl::client::Client::new(channel, protocol_name) }
1369    }
1370
1371    /// Get a Stream of events from the remote end of the protocol.
1372    ///
1373    /// # Panics
1374    ///
1375    /// Panics if the event stream was already taken.
1376    pub fn take_event_stream(&self) -> VirtioBlockEventStream {
1377        VirtioBlockEventStream { event_receiver: self.client.take_event_receiver() }
1378    }
1379
1380    /// Configure a `queue` for the device. This specifies the `size` and the
1381    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1382    pub fn r#configure_queue(
1383        &self,
1384        mut queue: u16,
1385        mut size: u16,
1386        mut desc: u64,
1387        mut avail: u64,
1388        mut used: u64,
1389    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1390        VirtioBlockProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
1391    }
1392
1393    /// Notify a `queue` for the device. Primarily used for black-box testing.
1394    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1395        VirtioBlockProxyInterface::r#notify_queue(self, queue)
1396    }
1397
1398    /// Ready a device. This provides the set of `negotiated_features` that the
1399    /// driver and device have agreed upon.
1400    pub fn r#ready(
1401        &self,
1402        mut negotiated_features: u32,
1403    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1404        VirtioBlockProxyInterface::r#ready(self, negotiated_features)
1405    }
1406
1407    /// Start the block device.
1408    pub fn r#start(
1409        &self,
1410        mut start_info: StartInfo,
1411        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1412    ) -> fidl::client::QueryResponseFut<(u64, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
1413    {
1414        VirtioBlockProxyInterface::r#start(self, start_info, spec)
1415    }
1416}
1417
1418impl VirtioBlockProxyInterface for VirtioBlockProxy {
1419    type ConfigureQueueResponseFut =
1420        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1421    fn r#configure_queue(
1422        &self,
1423        mut queue: u16,
1424        mut size: u16,
1425        mut desc: u64,
1426        mut avail: u64,
1427        mut used: u64,
1428    ) -> Self::ConfigureQueueResponseFut {
1429        fn _decode(
1430            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1431        ) -> Result<(), fidl::Error> {
1432            let _response = fidl::client::decode_transaction_body::<
1433                fidl::encoding::EmptyPayload,
1434                fidl::encoding::DefaultFuchsiaResourceDialect,
1435                0x72b44fb963480b11,
1436            >(_buf?)?;
1437            Ok(_response)
1438        }
1439        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
1440            (queue, size, desc, avail, used),
1441            0x72b44fb963480b11,
1442            fidl::encoding::DynamicFlags::empty(),
1443            _decode,
1444        )
1445    }
1446
1447    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1448        self.client.send::<VirtioDeviceNotifyQueueRequest>(
1449            (queue,),
1450            0x6e3a61d652499244,
1451            fidl::encoding::DynamicFlags::empty(),
1452        )
1453    }
1454
1455    type ReadyResponseFut =
1456        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1457    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
1458        fn _decode(
1459            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1460        ) -> Result<(), fidl::Error> {
1461            let _response = fidl::client::decode_transaction_body::<
1462                fidl::encoding::EmptyPayload,
1463                fidl::encoding::DefaultFuchsiaResourceDialect,
1464                0x45707654f5d23c3f,
1465            >(_buf?)?;
1466            Ok(_response)
1467        }
1468        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
1469            (negotiated_features,),
1470            0x45707654f5d23c3f,
1471            fidl::encoding::DynamicFlags::empty(),
1472            _decode,
1473        )
1474    }
1475
1476    type StartResponseFut =
1477        fidl::client::QueryResponseFut<(u64, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
1478    fn r#start(
1479        &self,
1480        mut start_info: StartInfo,
1481        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1482    ) -> Self::StartResponseFut {
1483        fn _decode(
1484            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1485        ) -> Result<(u64, u32), fidl::Error> {
1486            let _response = fidl::client::decode_transaction_body::<
1487                VirtioBlockStartResponse,
1488                fidl::encoding::DefaultFuchsiaResourceDialect,
1489                0x5ef6a4b9ce9adcb2,
1490            >(_buf?)?;
1491            Ok((_response.capacity, _response.block_size))
1492        }
1493        self.client.send_query_and_decode::<VirtioBlockStartRequest, (u64, u32)>(
1494            (&mut start_info, &mut spec),
1495            0x5ef6a4b9ce9adcb2,
1496            fidl::encoding::DynamicFlags::empty(),
1497            _decode,
1498        )
1499    }
1500}
1501
1502pub struct VirtioBlockEventStream {
1503    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1504}
1505
1506impl std::marker::Unpin for VirtioBlockEventStream {}
1507
1508impl futures::stream::FusedStream for VirtioBlockEventStream {
1509    fn is_terminated(&self) -> bool {
1510        self.event_receiver.is_terminated()
1511    }
1512}
1513
1514impl futures::Stream for VirtioBlockEventStream {
1515    type Item = Result<VirtioBlockEvent, fidl::Error>;
1516
1517    fn poll_next(
1518        mut self: std::pin::Pin<&mut Self>,
1519        cx: &mut std::task::Context<'_>,
1520    ) -> std::task::Poll<Option<Self::Item>> {
1521        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1522            &mut self.event_receiver,
1523            cx
1524        )?) {
1525            Some(buf) => std::task::Poll::Ready(Some(VirtioBlockEvent::decode(buf))),
1526            None => std::task::Poll::Ready(None),
1527        }
1528    }
1529}
1530
1531#[derive(Debug)]
1532pub enum VirtioBlockEvent {}
1533
1534impl VirtioBlockEvent {
1535    /// Decodes a message buffer as a [`VirtioBlockEvent`].
1536    fn decode(
1537        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1538    ) -> Result<VirtioBlockEvent, fidl::Error> {
1539        let (bytes, _handles) = buf.split_mut();
1540        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1541        debug_assert_eq!(tx_header.tx_id, 0);
1542        match tx_header.ordinal {
1543            _ => Err(fidl::Error::UnknownOrdinal {
1544                ordinal: tx_header.ordinal,
1545                protocol_name: <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1546            }),
1547        }
1548    }
1549}
1550
1551/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioBlock.
1552pub struct VirtioBlockRequestStream {
1553    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1554    is_terminated: bool,
1555}
1556
1557impl std::marker::Unpin for VirtioBlockRequestStream {}
1558
1559impl futures::stream::FusedStream for VirtioBlockRequestStream {
1560    fn is_terminated(&self) -> bool {
1561        self.is_terminated
1562    }
1563}
1564
1565impl fidl::endpoints::RequestStream for VirtioBlockRequestStream {
1566    type Protocol = VirtioBlockMarker;
1567    type ControlHandle = VirtioBlockControlHandle;
1568
1569    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1570        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1571    }
1572
1573    fn control_handle(&self) -> Self::ControlHandle {
1574        VirtioBlockControlHandle { inner: self.inner.clone() }
1575    }
1576
1577    fn into_inner(
1578        self,
1579    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1580    {
1581        (self.inner, self.is_terminated)
1582    }
1583
1584    fn from_inner(
1585        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1586        is_terminated: bool,
1587    ) -> Self {
1588        Self { inner, is_terminated }
1589    }
1590}
1591
1592impl futures::Stream for VirtioBlockRequestStream {
1593    type Item = Result<VirtioBlockRequest, fidl::Error>;
1594
1595    fn poll_next(
1596        mut self: std::pin::Pin<&mut Self>,
1597        cx: &mut std::task::Context<'_>,
1598    ) -> std::task::Poll<Option<Self::Item>> {
1599        let this = &mut *self;
1600        if this.inner.check_shutdown(cx) {
1601            this.is_terminated = true;
1602            return std::task::Poll::Ready(None);
1603        }
1604        if this.is_terminated {
1605            panic!("polled VirtioBlockRequestStream after completion");
1606        }
1607        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1608            |bytes, handles| {
1609                match this.inner.channel().read_etc(cx, bytes, handles) {
1610                    std::task::Poll::Ready(Ok(())) => {}
1611                    std::task::Poll::Pending => return std::task::Poll::Pending,
1612                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1613                        this.is_terminated = true;
1614                        return std::task::Poll::Ready(None);
1615                    }
1616                    std::task::Poll::Ready(Err(e)) => {
1617                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1618                            e.into(),
1619                        ))))
1620                    }
1621                }
1622
1623                // A message has been received from the channel
1624                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1625
1626                std::task::Poll::Ready(Some(match header.ordinal {
1627                    0x72b44fb963480b11 => {
1628                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1629                        let mut req = fidl::new_empty!(
1630                            VirtioDeviceConfigureQueueRequest,
1631                            fidl::encoding::DefaultFuchsiaResourceDialect
1632                        );
1633                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
1634                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1635                        Ok(VirtioBlockRequest::ConfigureQueue {
1636                            queue: req.queue,
1637                            size: req.size,
1638                            desc: req.desc,
1639                            avail: req.avail,
1640                            used: req.used,
1641
1642                            responder: VirtioBlockConfigureQueueResponder {
1643                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1644                                tx_id: header.tx_id,
1645                            },
1646                        })
1647                    }
1648                    0x6e3a61d652499244 => {
1649                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1650                        let mut req = fidl::new_empty!(
1651                            VirtioDeviceNotifyQueueRequest,
1652                            fidl::encoding::DefaultFuchsiaResourceDialect
1653                        );
1654                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
1655                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1656                        Ok(VirtioBlockRequest::NotifyQueue { queue: req.queue, control_handle })
1657                    }
1658                    0x45707654f5d23c3f => {
1659                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1660                        let mut req = fidl::new_empty!(
1661                            VirtioDeviceReadyRequest,
1662                            fidl::encoding::DefaultFuchsiaResourceDialect
1663                        );
1664                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
1665                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1666                        Ok(VirtioBlockRequest::Ready {
1667                            negotiated_features: req.negotiated_features,
1668
1669                            responder: VirtioBlockReadyResponder {
1670                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1671                                tx_id: header.tx_id,
1672                            },
1673                        })
1674                    }
1675                    0x5ef6a4b9ce9adcb2 => {
1676                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1677                        let mut req = fidl::new_empty!(
1678                            VirtioBlockStartRequest,
1679                            fidl::encoding::DefaultFuchsiaResourceDialect
1680                        );
1681                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioBlockStartRequest>(&header, _body_bytes, handles, &mut req)?;
1682                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1683                        Ok(VirtioBlockRequest::Start {
1684                            start_info: req.start_info,
1685                            spec: req.spec,
1686
1687                            responder: VirtioBlockStartResponder {
1688                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1689                                tx_id: header.tx_id,
1690                            },
1691                        })
1692                    }
1693                    _ => Err(fidl::Error::UnknownOrdinal {
1694                        ordinal: header.ordinal,
1695                        protocol_name:
1696                            <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1697                    }),
1698                }))
1699            },
1700        )
1701    }
1702}
1703
1704#[derive(Debug)]
1705pub enum VirtioBlockRequest {
1706    /// Configure a `queue` for the device. This specifies the `size` and the
1707    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1708    ConfigureQueue {
1709        queue: u16,
1710        size: u16,
1711        desc: u64,
1712        avail: u64,
1713        used: u64,
1714        responder: VirtioBlockConfigureQueueResponder,
1715    },
1716    /// Notify a `queue` for the device. Primarily used for black-box testing.
1717    NotifyQueue { queue: u16, control_handle: VirtioBlockControlHandle },
1718    /// Ready a device. This provides the set of `negotiated_features` that the
1719    /// driver and device have agreed upon.
1720    Ready { negotiated_features: u32, responder: VirtioBlockReadyResponder },
1721    /// Start the block device.
1722    Start {
1723        start_info: StartInfo,
1724        spec: fidl_fuchsia_virtualization::BlockSpec,
1725        responder: VirtioBlockStartResponder,
1726    },
1727}
1728
1729impl VirtioBlockRequest {
1730    #[allow(irrefutable_let_patterns)]
1731    pub fn into_configure_queue(
1732        self,
1733    ) -> Option<(u16, u16, u64, u64, u64, VirtioBlockConfigureQueueResponder)> {
1734        if let VirtioBlockRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
1735            self
1736        {
1737            Some((queue, size, desc, avail, used, responder))
1738        } else {
1739            None
1740        }
1741    }
1742
1743    #[allow(irrefutable_let_patterns)]
1744    pub fn into_notify_queue(self) -> Option<(u16, VirtioBlockControlHandle)> {
1745        if let VirtioBlockRequest::NotifyQueue { queue, control_handle } = self {
1746            Some((queue, control_handle))
1747        } else {
1748            None
1749        }
1750    }
1751
1752    #[allow(irrefutable_let_patterns)]
1753    pub fn into_ready(self) -> Option<(u32, VirtioBlockReadyResponder)> {
1754        if let VirtioBlockRequest::Ready { negotiated_features, responder } = self {
1755            Some((negotiated_features, responder))
1756        } else {
1757            None
1758        }
1759    }
1760
1761    #[allow(irrefutable_let_patterns)]
1762    pub fn into_start(
1763        self,
1764    ) -> Option<(StartInfo, fidl_fuchsia_virtualization::BlockSpec, VirtioBlockStartResponder)>
1765    {
1766        if let VirtioBlockRequest::Start { start_info, spec, responder } = self {
1767            Some((start_info, spec, responder))
1768        } else {
1769            None
1770        }
1771    }
1772
1773    /// Name of the method defined in FIDL
1774    pub fn method_name(&self) -> &'static str {
1775        match *self {
1776            VirtioBlockRequest::ConfigureQueue { .. } => "configure_queue",
1777            VirtioBlockRequest::NotifyQueue { .. } => "notify_queue",
1778            VirtioBlockRequest::Ready { .. } => "ready",
1779            VirtioBlockRequest::Start { .. } => "start",
1780        }
1781    }
1782}
1783
1784#[derive(Debug, Clone)]
1785pub struct VirtioBlockControlHandle {
1786    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1787}
1788
1789impl fidl::endpoints::ControlHandle for VirtioBlockControlHandle {
1790    fn shutdown(&self) {
1791        self.inner.shutdown()
1792    }
1793    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1794        self.inner.shutdown_with_epitaph(status)
1795    }
1796
1797    fn is_closed(&self) -> bool {
1798        self.inner.channel().is_closed()
1799    }
1800    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1801        self.inner.channel().on_closed()
1802    }
1803
1804    #[cfg(target_os = "fuchsia")]
1805    fn signal_peer(
1806        &self,
1807        clear_mask: zx::Signals,
1808        set_mask: zx::Signals,
1809    ) -> Result<(), zx_status::Status> {
1810        use fidl::Peered;
1811        self.inner.channel().signal_peer(clear_mask, set_mask)
1812    }
1813}
1814
1815impl VirtioBlockControlHandle {}
1816
1817#[must_use = "FIDL methods require a response to be sent"]
1818#[derive(Debug)]
1819pub struct VirtioBlockConfigureQueueResponder {
1820    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1821    tx_id: u32,
1822}
1823
1824/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1825/// if the responder is dropped without sending a response, so that the client
1826/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1827impl std::ops::Drop for VirtioBlockConfigureQueueResponder {
1828    fn drop(&mut self) {
1829        self.control_handle.shutdown();
1830        // Safety: drops once, never accessed again
1831        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1832    }
1833}
1834
1835impl fidl::endpoints::Responder for VirtioBlockConfigureQueueResponder {
1836    type ControlHandle = VirtioBlockControlHandle;
1837
1838    fn control_handle(&self) -> &VirtioBlockControlHandle {
1839        &self.control_handle
1840    }
1841
1842    fn drop_without_shutdown(mut self) {
1843        // Safety: drops once, never accessed again due to mem::forget
1844        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1845        // Prevent Drop from running (which would shut down the channel)
1846        std::mem::forget(self);
1847    }
1848}
1849
1850impl VirtioBlockConfigureQueueResponder {
1851    /// Sends a response to the FIDL transaction.
1852    ///
1853    /// Sets the channel to shutdown if an error occurs.
1854    pub fn send(self) -> Result<(), fidl::Error> {
1855        let _result = self.send_raw();
1856        if _result.is_err() {
1857            self.control_handle.shutdown();
1858        }
1859        self.drop_without_shutdown();
1860        _result
1861    }
1862
1863    /// Similar to "send" but does not shutdown the channel if an error occurs.
1864    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1865        let _result = self.send_raw();
1866        self.drop_without_shutdown();
1867        _result
1868    }
1869
1870    fn send_raw(&self) -> Result<(), fidl::Error> {
1871        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1872            (),
1873            self.tx_id,
1874            0x72b44fb963480b11,
1875            fidl::encoding::DynamicFlags::empty(),
1876        )
1877    }
1878}
1879
1880#[must_use = "FIDL methods require a response to be sent"]
1881#[derive(Debug)]
1882pub struct VirtioBlockReadyResponder {
1883    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1884    tx_id: u32,
1885}
1886
1887/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1888/// if the responder is dropped without sending a response, so that the client
1889/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1890impl std::ops::Drop for VirtioBlockReadyResponder {
1891    fn drop(&mut self) {
1892        self.control_handle.shutdown();
1893        // Safety: drops once, never accessed again
1894        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1895    }
1896}
1897
1898impl fidl::endpoints::Responder for VirtioBlockReadyResponder {
1899    type ControlHandle = VirtioBlockControlHandle;
1900
1901    fn control_handle(&self) -> &VirtioBlockControlHandle {
1902        &self.control_handle
1903    }
1904
1905    fn drop_without_shutdown(mut self) {
1906        // Safety: drops once, never accessed again due to mem::forget
1907        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1908        // Prevent Drop from running (which would shut down the channel)
1909        std::mem::forget(self);
1910    }
1911}
1912
1913impl VirtioBlockReadyResponder {
1914    /// Sends a response to the FIDL transaction.
1915    ///
1916    /// Sets the channel to shutdown if an error occurs.
1917    pub fn send(self) -> Result<(), fidl::Error> {
1918        let _result = self.send_raw();
1919        if _result.is_err() {
1920            self.control_handle.shutdown();
1921        }
1922        self.drop_without_shutdown();
1923        _result
1924    }
1925
1926    /// Similar to "send" but does not shutdown the channel if an error occurs.
1927    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1928        let _result = self.send_raw();
1929        self.drop_without_shutdown();
1930        _result
1931    }
1932
1933    fn send_raw(&self) -> Result<(), fidl::Error> {
1934        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1935            (),
1936            self.tx_id,
1937            0x45707654f5d23c3f,
1938            fidl::encoding::DynamicFlags::empty(),
1939        )
1940    }
1941}
1942
1943#[must_use = "FIDL methods require a response to be sent"]
1944#[derive(Debug)]
1945pub struct VirtioBlockStartResponder {
1946    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1947    tx_id: u32,
1948}
1949
1950/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1951/// if the responder is dropped without sending a response, so that the client
1952/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1953impl std::ops::Drop for VirtioBlockStartResponder {
1954    fn drop(&mut self) {
1955        self.control_handle.shutdown();
1956        // Safety: drops once, never accessed again
1957        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1958    }
1959}
1960
1961impl fidl::endpoints::Responder for VirtioBlockStartResponder {
1962    type ControlHandle = VirtioBlockControlHandle;
1963
1964    fn control_handle(&self) -> &VirtioBlockControlHandle {
1965        &self.control_handle
1966    }
1967
1968    fn drop_without_shutdown(mut self) {
1969        // Safety: drops once, never accessed again due to mem::forget
1970        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1971        // Prevent Drop from running (which would shut down the channel)
1972        std::mem::forget(self);
1973    }
1974}
1975
1976impl VirtioBlockStartResponder {
1977    /// Sends a response to the FIDL transaction.
1978    ///
1979    /// Sets the channel to shutdown if an error occurs.
1980    pub fn send(self, mut capacity: u64, mut block_size: u32) -> Result<(), fidl::Error> {
1981        let _result = self.send_raw(capacity, block_size);
1982        if _result.is_err() {
1983            self.control_handle.shutdown();
1984        }
1985        self.drop_without_shutdown();
1986        _result
1987    }
1988
1989    /// Similar to "send" but does not shutdown the channel if an error occurs.
1990    pub fn send_no_shutdown_on_err(
1991        self,
1992        mut capacity: u64,
1993        mut block_size: u32,
1994    ) -> Result<(), fidl::Error> {
1995        let _result = self.send_raw(capacity, block_size);
1996        self.drop_without_shutdown();
1997        _result
1998    }
1999
2000    fn send_raw(&self, mut capacity: u64, mut block_size: u32) -> Result<(), fidl::Error> {
2001        self.control_handle.inner.send::<VirtioBlockStartResponse>(
2002            (capacity, block_size),
2003            self.tx_id,
2004            0x5ef6a4b9ce9adcb2,
2005            fidl::encoding::DynamicFlags::empty(),
2006        )
2007    }
2008}
2009
2010#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2011pub struct VirtioConsoleMarker;
2012
2013impl fidl::endpoints::ProtocolMarker for VirtioConsoleMarker {
2014    type Proxy = VirtioConsoleProxy;
2015    type RequestStream = VirtioConsoleRequestStream;
2016    #[cfg(target_os = "fuchsia")]
2017    type SynchronousProxy = VirtioConsoleSynchronousProxy;
2018
2019    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioConsole";
2020}
2021impl fidl::endpoints::DiscoverableProtocolMarker for VirtioConsoleMarker {}
2022
2023pub trait VirtioConsoleProxyInterface: Send + Sync {
2024    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2025    fn r#configure_queue(
2026        &self,
2027        queue: u16,
2028        size: u16,
2029        desc: u64,
2030        avail: u64,
2031        used: u64,
2032    ) -> Self::ConfigureQueueResponseFut;
2033    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
2034    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2035    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
2036    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2037    fn r#start(&self, start_info: StartInfo, socket: fidl::Socket) -> Self::StartResponseFut;
2038}
2039#[derive(Debug)]
2040#[cfg(target_os = "fuchsia")]
2041pub struct VirtioConsoleSynchronousProxy {
2042    client: fidl::client::sync::Client,
2043}
2044
2045#[cfg(target_os = "fuchsia")]
2046impl fidl::endpoints::SynchronousProxy for VirtioConsoleSynchronousProxy {
2047    type Proxy = VirtioConsoleProxy;
2048    type Protocol = VirtioConsoleMarker;
2049
2050    fn from_channel(inner: fidl::Channel) -> Self {
2051        Self::new(inner)
2052    }
2053
2054    fn into_channel(self) -> fidl::Channel {
2055        self.client.into_channel()
2056    }
2057
2058    fn as_channel(&self) -> &fidl::Channel {
2059        self.client.as_channel()
2060    }
2061}
2062
2063#[cfg(target_os = "fuchsia")]
2064impl VirtioConsoleSynchronousProxy {
2065    pub fn new(channel: fidl::Channel) -> Self {
2066        let protocol_name = <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2067        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2068    }
2069
2070    pub fn into_channel(self) -> fidl::Channel {
2071        self.client.into_channel()
2072    }
2073
2074    /// Waits until an event arrives and returns it. It is safe for other
2075    /// threads to make concurrent requests while waiting for an event.
2076    pub fn wait_for_event(
2077        &self,
2078        deadline: zx::MonotonicInstant,
2079    ) -> Result<VirtioConsoleEvent, fidl::Error> {
2080        VirtioConsoleEvent::decode(self.client.wait_for_event(deadline)?)
2081    }
2082
2083    /// Configure a `queue` for the device. This specifies the `size` and the
2084    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2085    pub fn r#configure_queue(
2086        &self,
2087        mut queue: u16,
2088        mut size: u16,
2089        mut desc: u64,
2090        mut avail: u64,
2091        mut used: u64,
2092        ___deadline: zx::MonotonicInstant,
2093    ) -> Result<(), fidl::Error> {
2094        let _response = self
2095            .client
2096            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
2097                (queue, size, desc, avail, used),
2098                0x72b44fb963480b11,
2099                fidl::encoding::DynamicFlags::empty(),
2100                ___deadline,
2101            )?;
2102        Ok(_response)
2103    }
2104
2105    /// Notify a `queue` for the device. Primarily used for black-box testing.
2106    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2107        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2108            (queue,),
2109            0x6e3a61d652499244,
2110            fidl::encoding::DynamicFlags::empty(),
2111        )
2112    }
2113
2114    /// Ready a device. This provides the set of `negotiated_features` that the
2115    /// driver and device have agreed upon.
2116    pub fn r#ready(
2117        &self,
2118        mut negotiated_features: u32,
2119        ___deadline: zx::MonotonicInstant,
2120    ) -> Result<(), fidl::Error> {
2121        let _response =
2122            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
2123                (negotiated_features,),
2124                0x45707654f5d23c3f,
2125                fidl::encoding::DynamicFlags::empty(),
2126                ___deadline,
2127            )?;
2128        Ok(_response)
2129    }
2130
2131    /// Start the console device. This uses `socket` to handle input and output.
2132    pub fn r#start(
2133        &self,
2134        mut start_info: StartInfo,
2135        mut socket: fidl::Socket,
2136        ___deadline: zx::MonotonicInstant,
2137    ) -> Result<(), fidl::Error> {
2138        let _response =
2139            self.client.send_query::<VirtioConsoleStartRequest, fidl::encoding::EmptyPayload>(
2140                (&mut start_info, socket),
2141                0x10a6267f2ab7e24c,
2142                fidl::encoding::DynamicFlags::empty(),
2143                ___deadline,
2144            )?;
2145        Ok(_response)
2146    }
2147}
2148
2149#[cfg(target_os = "fuchsia")]
2150impl From<VirtioConsoleSynchronousProxy> for zx::Handle {
2151    fn from(value: VirtioConsoleSynchronousProxy) -> Self {
2152        value.into_channel().into()
2153    }
2154}
2155
2156#[cfg(target_os = "fuchsia")]
2157impl From<fidl::Channel> for VirtioConsoleSynchronousProxy {
2158    fn from(value: fidl::Channel) -> Self {
2159        Self::new(value)
2160    }
2161}
2162
2163#[derive(Debug, Clone)]
2164pub struct VirtioConsoleProxy {
2165    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2166}
2167
2168impl fidl::endpoints::Proxy for VirtioConsoleProxy {
2169    type Protocol = VirtioConsoleMarker;
2170
2171    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2172        Self::new(inner)
2173    }
2174
2175    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2176        self.client.into_channel().map_err(|client| Self { client })
2177    }
2178
2179    fn as_channel(&self) -> &::fidl::AsyncChannel {
2180        self.client.as_channel()
2181    }
2182}
2183
2184impl VirtioConsoleProxy {
2185    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioConsole.
2186    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2187        let protocol_name = <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2188        Self { client: fidl::client::Client::new(channel, protocol_name) }
2189    }
2190
2191    /// Get a Stream of events from the remote end of the protocol.
2192    ///
2193    /// # Panics
2194    ///
2195    /// Panics if the event stream was already taken.
2196    pub fn take_event_stream(&self) -> VirtioConsoleEventStream {
2197        VirtioConsoleEventStream { event_receiver: self.client.take_event_receiver() }
2198    }
2199
2200    /// Configure a `queue` for the device. This specifies the `size` and the
2201    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2202    pub fn r#configure_queue(
2203        &self,
2204        mut queue: u16,
2205        mut size: u16,
2206        mut desc: u64,
2207        mut avail: u64,
2208        mut used: u64,
2209    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2210        VirtioConsoleProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
2211    }
2212
2213    /// Notify a `queue` for the device. Primarily used for black-box testing.
2214    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2215        VirtioConsoleProxyInterface::r#notify_queue(self, queue)
2216    }
2217
2218    /// Ready a device. This provides the set of `negotiated_features` that the
2219    /// driver and device have agreed upon.
2220    pub fn r#ready(
2221        &self,
2222        mut negotiated_features: u32,
2223    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2224        VirtioConsoleProxyInterface::r#ready(self, negotiated_features)
2225    }
2226
2227    /// Start the console device. This uses `socket` to handle input and output.
2228    pub fn r#start(
2229        &self,
2230        mut start_info: StartInfo,
2231        mut socket: fidl::Socket,
2232    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2233        VirtioConsoleProxyInterface::r#start(self, start_info, socket)
2234    }
2235}
2236
2237impl VirtioConsoleProxyInterface for VirtioConsoleProxy {
2238    type ConfigureQueueResponseFut =
2239        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2240    fn r#configure_queue(
2241        &self,
2242        mut queue: u16,
2243        mut size: u16,
2244        mut desc: u64,
2245        mut avail: u64,
2246        mut used: u64,
2247    ) -> Self::ConfigureQueueResponseFut {
2248        fn _decode(
2249            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2250        ) -> Result<(), fidl::Error> {
2251            let _response = fidl::client::decode_transaction_body::<
2252                fidl::encoding::EmptyPayload,
2253                fidl::encoding::DefaultFuchsiaResourceDialect,
2254                0x72b44fb963480b11,
2255            >(_buf?)?;
2256            Ok(_response)
2257        }
2258        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
2259            (queue, size, desc, avail, used),
2260            0x72b44fb963480b11,
2261            fidl::encoding::DynamicFlags::empty(),
2262            _decode,
2263        )
2264    }
2265
2266    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2267        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2268            (queue,),
2269            0x6e3a61d652499244,
2270            fidl::encoding::DynamicFlags::empty(),
2271        )
2272    }
2273
2274    type ReadyResponseFut =
2275        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2276    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
2277        fn _decode(
2278            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2279        ) -> Result<(), fidl::Error> {
2280            let _response = fidl::client::decode_transaction_body::<
2281                fidl::encoding::EmptyPayload,
2282                fidl::encoding::DefaultFuchsiaResourceDialect,
2283                0x45707654f5d23c3f,
2284            >(_buf?)?;
2285            Ok(_response)
2286        }
2287        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
2288            (negotiated_features,),
2289            0x45707654f5d23c3f,
2290            fidl::encoding::DynamicFlags::empty(),
2291            _decode,
2292        )
2293    }
2294
2295    type StartResponseFut =
2296        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2297    fn r#start(
2298        &self,
2299        mut start_info: StartInfo,
2300        mut socket: fidl::Socket,
2301    ) -> Self::StartResponseFut {
2302        fn _decode(
2303            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2304        ) -> Result<(), fidl::Error> {
2305            let _response = fidl::client::decode_transaction_body::<
2306                fidl::encoding::EmptyPayload,
2307                fidl::encoding::DefaultFuchsiaResourceDialect,
2308                0x10a6267f2ab7e24c,
2309            >(_buf?)?;
2310            Ok(_response)
2311        }
2312        self.client.send_query_and_decode::<VirtioConsoleStartRequest, ()>(
2313            (&mut start_info, socket),
2314            0x10a6267f2ab7e24c,
2315            fidl::encoding::DynamicFlags::empty(),
2316            _decode,
2317        )
2318    }
2319}
2320
2321pub struct VirtioConsoleEventStream {
2322    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2323}
2324
2325impl std::marker::Unpin for VirtioConsoleEventStream {}
2326
2327impl futures::stream::FusedStream for VirtioConsoleEventStream {
2328    fn is_terminated(&self) -> bool {
2329        self.event_receiver.is_terminated()
2330    }
2331}
2332
2333impl futures::Stream for VirtioConsoleEventStream {
2334    type Item = Result<VirtioConsoleEvent, fidl::Error>;
2335
2336    fn poll_next(
2337        mut self: std::pin::Pin<&mut Self>,
2338        cx: &mut std::task::Context<'_>,
2339    ) -> std::task::Poll<Option<Self::Item>> {
2340        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2341            &mut self.event_receiver,
2342            cx
2343        )?) {
2344            Some(buf) => std::task::Poll::Ready(Some(VirtioConsoleEvent::decode(buf))),
2345            None => std::task::Poll::Ready(None),
2346        }
2347    }
2348}
2349
2350#[derive(Debug)]
2351pub enum VirtioConsoleEvent {}
2352
2353impl VirtioConsoleEvent {
2354    /// Decodes a message buffer as a [`VirtioConsoleEvent`].
2355    fn decode(
2356        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2357    ) -> Result<VirtioConsoleEvent, fidl::Error> {
2358        let (bytes, _handles) = buf.split_mut();
2359        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2360        debug_assert_eq!(tx_header.tx_id, 0);
2361        match tx_header.ordinal {
2362            _ => Err(fidl::Error::UnknownOrdinal {
2363                ordinal: tx_header.ordinal,
2364                protocol_name: <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2365            }),
2366        }
2367    }
2368}
2369
2370/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioConsole.
2371pub struct VirtioConsoleRequestStream {
2372    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2373    is_terminated: bool,
2374}
2375
2376impl std::marker::Unpin for VirtioConsoleRequestStream {}
2377
2378impl futures::stream::FusedStream for VirtioConsoleRequestStream {
2379    fn is_terminated(&self) -> bool {
2380        self.is_terminated
2381    }
2382}
2383
2384impl fidl::endpoints::RequestStream for VirtioConsoleRequestStream {
2385    type Protocol = VirtioConsoleMarker;
2386    type ControlHandle = VirtioConsoleControlHandle;
2387
2388    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2389        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2390    }
2391
2392    fn control_handle(&self) -> Self::ControlHandle {
2393        VirtioConsoleControlHandle { inner: self.inner.clone() }
2394    }
2395
2396    fn into_inner(
2397        self,
2398    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2399    {
2400        (self.inner, self.is_terminated)
2401    }
2402
2403    fn from_inner(
2404        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2405        is_terminated: bool,
2406    ) -> Self {
2407        Self { inner, is_terminated }
2408    }
2409}
2410
2411impl futures::Stream for VirtioConsoleRequestStream {
2412    type Item = Result<VirtioConsoleRequest, fidl::Error>;
2413
2414    fn poll_next(
2415        mut self: std::pin::Pin<&mut Self>,
2416        cx: &mut std::task::Context<'_>,
2417    ) -> std::task::Poll<Option<Self::Item>> {
2418        let this = &mut *self;
2419        if this.inner.check_shutdown(cx) {
2420            this.is_terminated = true;
2421            return std::task::Poll::Ready(None);
2422        }
2423        if this.is_terminated {
2424            panic!("polled VirtioConsoleRequestStream after completion");
2425        }
2426        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2427            |bytes, handles| {
2428                match this.inner.channel().read_etc(cx, bytes, handles) {
2429                    std::task::Poll::Ready(Ok(())) => {}
2430                    std::task::Poll::Pending => return std::task::Poll::Pending,
2431                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2432                        this.is_terminated = true;
2433                        return std::task::Poll::Ready(None);
2434                    }
2435                    std::task::Poll::Ready(Err(e)) => {
2436                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2437                            e.into(),
2438                        ))))
2439                    }
2440                }
2441
2442                // A message has been received from the channel
2443                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2444
2445                std::task::Poll::Ready(Some(match header.ordinal {
2446                    0x72b44fb963480b11 => {
2447                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2448                        let mut req = fidl::new_empty!(
2449                            VirtioDeviceConfigureQueueRequest,
2450                            fidl::encoding::DefaultFuchsiaResourceDialect
2451                        );
2452                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
2453                        let control_handle =
2454                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2455                        Ok(VirtioConsoleRequest::ConfigureQueue {
2456                            queue: req.queue,
2457                            size: req.size,
2458                            desc: req.desc,
2459                            avail: req.avail,
2460                            used: req.used,
2461
2462                            responder: VirtioConsoleConfigureQueueResponder {
2463                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2464                                tx_id: header.tx_id,
2465                            },
2466                        })
2467                    }
2468                    0x6e3a61d652499244 => {
2469                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2470                        let mut req = fidl::new_empty!(
2471                            VirtioDeviceNotifyQueueRequest,
2472                            fidl::encoding::DefaultFuchsiaResourceDialect
2473                        );
2474                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
2475                        let control_handle =
2476                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2477                        Ok(VirtioConsoleRequest::NotifyQueue { queue: req.queue, control_handle })
2478                    }
2479                    0x45707654f5d23c3f => {
2480                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2481                        let mut req = fidl::new_empty!(
2482                            VirtioDeviceReadyRequest,
2483                            fidl::encoding::DefaultFuchsiaResourceDialect
2484                        );
2485                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
2486                        let control_handle =
2487                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2488                        Ok(VirtioConsoleRequest::Ready {
2489                            negotiated_features: req.negotiated_features,
2490
2491                            responder: VirtioConsoleReadyResponder {
2492                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2493                                tx_id: header.tx_id,
2494                            },
2495                        })
2496                    }
2497                    0x10a6267f2ab7e24c => {
2498                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2499                        let mut req = fidl::new_empty!(
2500                            VirtioConsoleStartRequest,
2501                            fidl::encoding::DefaultFuchsiaResourceDialect
2502                        );
2503                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioConsoleStartRequest>(&header, _body_bytes, handles, &mut req)?;
2504                        let control_handle =
2505                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2506                        Ok(VirtioConsoleRequest::Start {
2507                            start_info: req.start_info,
2508                            socket: req.socket,
2509
2510                            responder: VirtioConsoleStartResponder {
2511                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2512                                tx_id: header.tx_id,
2513                            },
2514                        })
2515                    }
2516                    _ => Err(fidl::Error::UnknownOrdinal {
2517                        ordinal: header.ordinal,
2518                        protocol_name:
2519                            <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2520                    }),
2521                }))
2522            },
2523        )
2524    }
2525}
2526
2527#[derive(Debug)]
2528pub enum VirtioConsoleRequest {
2529    /// Configure a `queue` for the device. This specifies the `size` and the
2530    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2531    ConfigureQueue {
2532        queue: u16,
2533        size: u16,
2534        desc: u64,
2535        avail: u64,
2536        used: u64,
2537        responder: VirtioConsoleConfigureQueueResponder,
2538    },
2539    /// Notify a `queue` for the device. Primarily used for black-box testing.
2540    NotifyQueue { queue: u16, control_handle: VirtioConsoleControlHandle },
2541    /// Ready a device. This provides the set of `negotiated_features` that the
2542    /// driver and device have agreed upon.
2543    Ready { negotiated_features: u32, responder: VirtioConsoleReadyResponder },
2544    /// Start the console device. This uses `socket` to handle input and output.
2545    Start { start_info: StartInfo, socket: fidl::Socket, responder: VirtioConsoleStartResponder },
2546}
2547
2548impl VirtioConsoleRequest {
2549    #[allow(irrefutable_let_patterns)]
2550    pub fn into_configure_queue(
2551        self,
2552    ) -> Option<(u16, u16, u64, u64, u64, VirtioConsoleConfigureQueueResponder)> {
2553        if let VirtioConsoleRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
2554            self
2555        {
2556            Some((queue, size, desc, avail, used, responder))
2557        } else {
2558            None
2559        }
2560    }
2561
2562    #[allow(irrefutable_let_patterns)]
2563    pub fn into_notify_queue(self) -> Option<(u16, VirtioConsoleControlHandle)> {
2564        if let VirtioConsoleRequest::NotifyQueue { queue, control_handle } = self {
2565            Some((queue, control_handle))
2566        } else {
2567            None
2568        }
2569    }
2570
2571    #[allow(irrefutable_let_patterns)]
2572    pub fn into_ready(self) -> Option<(u32, VirtioConsoleReadyResponder)> {
2573        if let VirtioConsoleRequest::Ready { negotiated_features, responder } = self {
2574            Some((negotiated_features, responder))
2575        } else {
2576            None
2577        }
2578    }
2579
2580    #[allow(irrefutable_let_patterns)]
2581    pub fn into_start(self) -> Option<(StartInfo, fidl::Socket, VirtioConsoleStartResponder)> {
2582        if let VirtioConsoleRequest::Start { start_info, socket, responder } = self {
2583            Some((start_info, socket, responder))
2584        } else {
2585            None
2586        }
2587    }
2588
2589    /// Name of the method defined in FIDL
2590    pub fn method_name(&self) -> &'static str {
2591        match *self {
2592            VirtioConsoleRequest::ConfigureQueue { .. } => "configure_queue",
2593            VirtioConsoleRequest::NotifyQueue { .. } => "notify_queue",
2594            VirtioConsoleRequest::Ready { .. } => "ready",
2595            VirtioConsoleRequest::Start { .. } => "start",
2596        }
2597    }
2598}
2599
2600#[derive(Debug, Clone)]
2601pub struct VirtioConsoleControlHandle {
2602    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2603}
2604
2605impl fidl::endpoints::ControlHandle for VirtioConsoleControlHandle {
2606    fn shutdown(&self) {
2607        self.inner.shutdown()
2608    }
2609    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2610        self.inner.shutdown_with_epitaph(status)
2611    }
2612
2613    fn is_closed(&self) -> bool {
2614        self.inner.channel().is_closed()
2615    }
2616    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2617        self.inner.channel().on_closed()
2618    }
2619
2620    #[cfg(target_os = "fuchsia")]
2621    fn signal_peer(
2622        &self,
2623        clear_mask: zx::Signals,
2624        set_mask: zx::Signals,
2625    ) -> Result<(), zx_status::Status> {
2626        use fidl::Peered;
2627        self.inner.channel().signal_peer(clear_mask, set_mask)
2628    }
2629}
2630
2631impl VirtioConsoleControlHandle {}
2632
2633#[must_use = "FIDL methods require a response to be sent"]
2634#[derive(Debug)]
2635pub struct VirtioConsoleConfigureQueueResponder {
2636    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2637    tx_id: u32,
2638}
2639
2640/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2641/// if the responder is dropped without sending a response, so that the client
2642/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2643impl std::ops::Drop for VirtioConsoleConfigureQueueResponder {
2644    fn drop(&mut self) {
2645        self.control_handle.shutdown();
2646        // Safety: drops once, never accessed again
2647        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2648    }
2649}
2650
2651impl fidl::endpoints::Responder for VirtioConsoleConfigureQueueResponder {
2652    type ControlHandle = VirtioConsoleControlHandle;
2653
2654    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2655        &self.control_handle
2656    }
2657
2658    fn drop_without_shutdown(mut self) {
2659        // Safety: drops once, never accessed again due to mem::forget
2660        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2661        // Prevent Drop from running (which would shut down the channel)
2662        std::mem::forget(self);
2663    }
2664}
2665
2666impl VirtioConsoleConfigureQueueResponder {
2667    /// Sends a response to the FIDL transaction.
2668    ///
2669    /// Sets the channel to shutdown if an error occurs.
2670    pub fn send(self) -> Result<(), fidl::Error> {
2671        let _result = self.send_raw();
2672        if _result.is_err() {
2673            self.control_handle.shutdown();
2674        }
2675        self.drop_without_shutdown();
2676        _result
2677    }
2678
2679    /// Similar to "send" but does not shutdown the channel if an error occurs.
2680    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2681        let _result = self.send_raw();
2682        self.drop_without_shutdown();
2683        _result
2684    }
2685
2686    fn send_raw(&self) -> Result<(), fidl::Error> {
2687        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2688            (),
2689            self.tx_id,
2690            0x72b44fb963480b11,
2691            fidl::encoding::DynamicFlags::empty(),
2692        )
2693    }
2694}
2695
2696#[must_use = "FIDL methods require a response to be sent"]
2697#[derive(Debug)]
2698pub struct VirtioConsoleReadyResponder {
2699    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2700    tx_id: u32,
2701}
2702
2703/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2704/// if the responder is dropped without sending a response, so that the client
2705/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2706impl std::ops::Drop for VirtioConsoleReadyResponder {
2707    fn drop(&mut self) {
2708        self.control_handle.shutdown();
2709        // Safety: drops once, never accessed again
2710        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2711    }
2712}
2713
2714impl fidl::endpoints::Responder for VirtioConsoleReadyResponder {
2715    type ControlHandle = VirtioConsoleControlHandle;
2716
2717    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2718        &self.control_handle
2719    }
2720
2721    fn drop_without_shutdown(mut self) {
2722        // Safety: drops once, never accessed again due to mem::forget
2723        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2724        // Prevent Drop from running (which would shut down the channel)
2725        std::mem::forget(self);
2726    }
2727}
2728
2729impl VirtioConsoleReadyResponder {
2730    /// Sends a response to the FIDL transaction.
2731    ///
2732    /// Sets the channel to shutdown if an error occurs.
2733    pub fn send(self) -> Result<(), fidl::Error> {
2734        let _result = self.send_raw();
2735        if _result.is_err() {
2736            self.control_handle.shutdown();
2737        }
2738        self.drop_without_shutdown();
2739        _result
2740    }
2741
2742    /// Similar to "send" but does not shutdown the channel if an error occurs.
2743    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2744        let _result = self.send_raw();
2745        self.drop_without_shutdown();
2746        _result
2747    }
2748
2749    fn send_raw(&self) -> Result<(), fidl::Error> {
2750        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2751            (),
2752            self.tx_id,
2753            0x45707654f5d23c3f,
2754            fidl::encoding::DynamicFlags::empty(),
2755        )
2756    }
2757}
2758
2759#[must_use = "FIDL methods require a response to be sent"]
2760#[derive(Debug)]
2761pub struct VirtioConsoleStartResponder {
2762    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2763    tx_id: u32,
2764}
2765
2766/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2767/// if the responder is dropped without sending a response, so that the client
2768/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2769impl std::ops::Drop for VirtioConsoleStartResponder {
2770    fn drop(&mut self) {
2771        self.control_handle.shutdown();
2772        // Safety: drops once, never accessed again
2773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2774    }
2775}
2776
2777impl fidl::endpoints::Responder for VirtioConsoleStartResponder {
2778    type ControlHandle = VirtioConsoleControlHandle;
2779
2780    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2781        &self.control_handle
2782    }
2783
2784    fn drop_without_shutdown(mut self) {
2785        // Safety: drops once, never accessed again due to mem::forget
2786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2787        // Prevent Drop from running (which would shut down the channel)
2788        std::mem::forget(self);
2789    }
2790}
2791
2792impl VirtioConsoleStartResponder {
2793    /// Sends a response to the FIDL transaction.
2794    ///
2795    /// Sets the channel to shutdown if an error occurs.
2796    pub fn send(self) -> Result<(), fidl::Error> {
2797        let _result = self.send_raw();
2798        if _result.is_err() {
2799            self.control_handle.shutdown();
2800        }
2801        self.drop_without_shutdown();
2802        _result
2803    }
2804
2805    /// Similar to "send" but does not shutdown the channel if an error occurs.
2806    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2807        let _result = self.send_raw();
2808        self.drop_without_shutdown();
2809        _result
2810    }
2811
2812    fn send_raw(&self) -> Result<(), fidl::Error> {
2813        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2814            (),
2815            self.tx_id,
2816            0x10a6267f2ab7e24c,
2817            fidl::encoding::DynamicFlags::empty(),
2818        )
2819    }
2820}
2821
2822#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2823pub struct VirtioDeviceMarker;
2824
2825impl fidl::endpoints::ProtocolMarker for VirtioDeviceMarker {
2826    type Proxy = VirtioDeviceProxy;
2827    type RequestStream = VirtioDeviceRequestStream;
2828    #[cfg(target_os = "fuchsia")]
2829    type SynchronousProxy = VirtioDeviceSynchronousProxy;
2830
2831    const DEBUG_NAME: &'static str = "(anonymous) VirtioDevice";
2832}
2833
2834pub trait VirtioDeviceProxyInterface: Send + Sync {
2835    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2836    fn r#configure_queue(
2837        &self,
2838        queue: u16,
2839        size: u16,
2840        desc: u64,
2841        avail: u64,
2842        used: u64,
2843    ) -> Self::ConfigureQueueResponseFut;
2844    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
2845    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2846    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
2847}
2848#[derive(Debug)]
2849#[cfg(target_os = "fuchsia")]
2850pub struct VirtioDeviceSynchronousProxy {
2851    client: fidl::client::sync::Client,
2852}
2853
2854#[cfg(target_os = "fuchsia")]
2855impl fidl::endpoints::SynchronousProxy for VirtioDeviceSynchronousProxy {
2856    type Proxy = VirtioDeviceProxy;
2857    type Protocol = VirtioDeviceMarker;
2858
2859    fn from_channel(inner: fidl::Channel) -> Self {
2860        Self::new(inner)
2861    }
2862
2863    fn into_channel(self) -> fidl::Channel {
2864        self.client.into_channel()
2865    }
2866
2867    fn as_channel(&self) -> &fidl::Channel {
2868        self.client.as_channel()
2869    }
2870}
2871
2872#[cfg(target_os = "fuchsia")]
2873impl VirtioDeviceSynchronousProxy {
2874    pub fn new(channel: fidl::Channel) -> Self {
2875        let protocol_name = <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2876        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2877    }
2878
2879    pub fn into_channel(self) -> fidl::Channel {
2880        self.client.into_channel()
2881    }
2882
2883    /// Waits until an event arrives and returns it. It is safe for other
2884    /// threads to make concurrent requests while waiting for an event.
2885    pub fn wait_for_event(
2886        &self,
2887        deadline: zx::MonotonicInstant,
2888    ) -> Result<VirtioDeviceEvent, fidl::Error> {
2889        VirtioDeviceEvent::decode(self.client.wait_for_event(deadline)?)
2890    }
2891
2892    /// Configure a `queue` for the device. This specifies the `size` and the
2893    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2894    pub fn r#configure_queue(
2895        &self,
2896        mut queue: u16,
2897        mut size: u16,
2898        mut desc: u64,
2899        mut avail: u64,
2900        mut used: u64,
2901        ___deadline: zx::MonotonicInstant,
2902    ) -> Result<(), fidl::Error> {
2903        let _response = self
2904            .client
2905            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
2906                (queue, size, desc, avail, used),
2907                0x72b44fb963480b11,
2908                fidl::encoding::DynamicFlags::empty(),
2909                ___deadline,
2910            )?;
2911        Ok(_response)
2912    }
2913
2914    /// Notify a `queue` for the device. Primarily used for black-box testing.
2915    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2916        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2917            (queue,),
2918            0x6e3a61d652499244,
2919            fidl::encoding::DynamicFlags::empty(),
2920        )
2921    }
2922
2923    /// Ready a device. This provides the set of `negotiated_features` that the
2924    /// driver and device have agreed upon.
2925    pub fn r#ready(
2926        &self,
2927        mut negotiated_features: u32,
2928        ___deadline: zx::MonotonicInstant,
2929    ) -> Result<(), fidl::Error> {
2930        let _response =
2931            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
2932                (negotiated_features,),
2933                0x45707654f5d23c3f,
2934                fidl::encoding::DynamicFlags::empty(),
2935                ___deadline,
2936            )?;
2937        Ok(_response)
2938    }
2939}
2940
2941#[cfg(target_os = "fuchsia")]
2942impl From<VirtioDeviceSynchronousProxy> for zx::Handle {
2943    fn from(value: VirtioDeviceSynchronousProxy) -> Self {
2944        value.into_channel().into()
2945    }
2946}
2947
2948#[cfg(target_os = "fuchsia")]
2949impl From<fidl::Channel> for VirtioDeviceSynchronousProxy {
2950    fn from(value: fidl::Channel) -> Self {
2951        Self::new(value)
2952    }
2953}
2954
2955#[derive(Debug, Clone)]
2956pub struct VirtioDeviceProxy {
2957    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2958}
2959
2960impl fidl::endpoints::Proxy for VirtioDeviceProxy {
2961    type Protocol = VirtioDeviceMarker;
2962
2963    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2964        Self::new(inner)
2965    }
2966
2967    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2968        self.client.into_channel().map_err(|client| Self { client })
2969    }
2970
2971    fn as_channel(&self) -> &::fidl::AsyncChannel {
2972        self.client.as_channel()
2973    }
2974}
2975
2976impl VirtioDeviceProxy {
2977    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioDevice.
2978    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2979        let protocol_name = <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2980        Self { client: fidl::client::Client::new(channel, protocol_name) }
2981    }
2982
2983    /// Get a Stream of events from the remote end of the protocol.
2984    ///
2985    /// # Panics
2986    ///
2987    /// Panics if the event stream was already taken.
2988    pub fn take_event_stream(&self) -> VirtioDeviceEventStream {
2989        VirtioDeviceEventStream { event_receiver: self.client.take_event_receiver() }
2990    }
2991
2992    /// Configure a `queue` for the device. This specifies the `size` and the
2993    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2994    pub fn r#configure_queue(
2995        &self,
2996        mut queue: u16,
2997        mut size: u16,
2998        mut desc: u64,
2999        mut avail: u64,
3000        mut used: u64,
3001    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3002        VirtioDeviceProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
3003    }
3004
3005    /// Notify a `queue` for the device. Primarily used for black-box testing.
3006    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3007        VirtioDeviceProxyInterface::r#notify_queue(self, queue)
3008    }
3009
3010    /// Ready a device. This provides the set of `negotiated_features` that the
3011    /// driver and device have agreed upon.
3012    pub fn r#ready(
3013        &self,
3014        mut negotiated_features: u32,
3015    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3016        VirtioDeviceProxyInterface::r#ready(self, negotiated_features)
3017    }
3018}
3019
3020impl VirtioDeviceProxyInterface for VirtioDeviceProxy {
3021    type ConfigureQueueResponseFut =
3022        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3023    fn r#configure_queue(
3024        &self,
3025        mut queue: u16,
3026        mut size: u16,
3027        mut desc: u64,
3028        mut avail: u64,
3029        mut used: u64,
3030    ) -> Self::ConfigureQueueResponseFut {
3031        fn _decode(
3032            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3033        ) -> Result<(), fidl::Error> {
3034            let _response = fidl::client::decode_transaction_body::<
3035                fidl::encoding::EmptyPayload,
3036                fidl::encoding::DefaultFuchsiaResourceDialect,
3037                0x72b44fb963480b11,
3038            >(_buf?)?;
3039            Ok(_response)
3040        }
3041        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
3042            (queue, size, desc, avail, used),
3043            0x72b44fb963480b11,
3044            fidl::encoding::DynamicFlags::empty(),
3045            _decode,
3046        )
3047    }
3048
3049    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3050        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3051            (queue,),
3052            0x6e3a61d652499244,
3053            fidl::encoding::DynamicFlags::empty(),
3054        )
3055    }
3056
3057    type ReadyResponseFut =
3058        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3059    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
3060        fn _decode(
3061            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3062        ) -> Result<(), fidl::Error> {
3063            let _response = fidl::client::decode_transaction_body::<
3064                fidl::encoding::EmptyPayload,
3065                fidl::encoding::DefaultFuchsiaResourceDialect,
3066                0x45707654f5d23c3f,
3067            >(_buf?)?;
3068            Ok(_response)
3069        }
3070        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
3071            (negotiated_features,),
3072            0x45707654f5d23c3f,
3073            fidl::encoding::DynamicFlags::empty(),
3074            _decode,
3075        )
3076    }
3077}
3078
3079pub struct VirtioDeviceEventStream {
3080    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3081}
3082
3083impl std::marker::Unpin for VirtioDeviceEventStream {}
3084
3085impl futures::stream::FusedStream for VirtioDeviceEventStream {
3086    fn is_terminated(&self) -> bool {
3087        self.event_receiver.is_terminated()
3088    }
3089}
3090
3091impl futures::Stream for VirtioDeviceEventStream {
3092    type Item = Result<VirtioDeviceEvent, fidl::Error>;
3093
3094    fn poll_next(
3095        mut self: std::pin::Pin<&mut Self>,
3096        cx: &mut std::task::Context<'_>,
3097    ) -> std::task::Poll<Option<Self::Item>> {
3098        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3099            &mut self.event_receiver,
3100            cx
3101        )?) {
3102            Some(buf) => std::task::Poll::Ready(Some(VirtioDeviceEvent::decode(buf))),
3103            None => std::task::Poll::Ready(None),
3104        }
3105    }
3106}
3107
3108#[derive(Debug)]
3109pub enum VirtioDeviceEvent {}
3110
3111impl VirtioDeviceEvent {
3112    /// Decodes a message buffer as a [`VirtioDeviceEvent`].
3113    fn decode(
3114        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3115    ) -> Result<VirtioDeviceEvent, fidl::Error> {
3116        let (bytes, _handles) = buf.split_mut();
3117        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3118        debug_assert_eq!(tx_header.tx_id, 0);
3119        match tx_header.ordinal {
3120            _ => Err(fidl::Error::UnknownOrdinal {
3121                ordinal: tx_header.ordinal,
3122                protocol_name: <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3123            }),
3124        }
3125    }
3126}
3127
3128/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioDevice.
3129pub struct VirtioDeviceRequestStream {
3130    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3131    is_terminated: bool,
3132}
3133
3134impl std::marker::Unpin for VirtioDeviceRequestStream {}
3135
3136impl futures::stream::FusedStream for VirtioDeviceRequestStream {
3137    fn is_terminated(&self) -> bool {
3138        self.is_terminated
3139    }
3140}
3141
3142impl fidl::endpoints::RequestStream for VirtioDeviceRequestStream {
3143    type Protocol = VirtioDeviceMarker;
3144    type ControlHandle = VirtioDeviceControlHandle;
3145
3146    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3147        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3148    }
3149
3150    fn control_handle(&self) -> Self::ControlHandle {
3151        VirtioDeviceControlHandle { inner: self.inner.clone() }
3152    }
3153
3154    fn into_inner(
3155        self,
3156    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3157    {
3158        (self.inner, self.is_terminated)
3159    }
3160
3161    fn from_inner(
3162        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3163        is_terminated: bool,
3164    ) -> Self {
3165        Self { inner, is_terminated }
3166    }
3167}
3168
3169impl futures::Stream for VirtioDeviceRequestStream {
3170    type Item = Result<VirtioDeviceRequest, fidl::Error>;
3171
3172    fn poll_next(
3173        mut self: std::pin::Pin<&mut Self>,
3174        cx: &mut std::task::Context<'_>,
3175    ) -> std::task::Poll<Option<Self::Item>> {
3176        let this = &mut *self;
3177        if this.inner.check_shutdown(cx) {
3178            this.is_terminated = true;
3179            return std::task::Poll::Ready(None);
3180        }
3181        if this.is_terminated {
3182            panic!("polled VirtioDeviceRequestStream after completion");
3183        }
3184        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3185            |bytes, handles| {
3186                match this.inner.channel().read_etc(cx, bytes, handles) {
3187                    std::task::Poll::Ready(Ok(())) => {}
3188                    std::task::Poll::Pending => return std::task::Poll::Pending,
3189                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3190                        this.is_terminated = true;
3191                        return std::task::Poll::Ready(None);
3192                    }
3193                    std::task::Poll::Ready(Err(e)) => {
3194                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3195                            e.into(),
3196                        ))))
3197                    }
3198                }
3199
3200                // A message has been received from the channel
3201                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3202
3203                std::task::Poll::Ready(Some(match header.ordinal {
3204                    0x72b44fb963480b11 => {
3205                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3206                        let mut req = fidl::new_empty!(
3207                            VirtioDeviceConfigureQueueRequest,
3208                            fidl::encoding::DefaultFuchsiaResourceDialect
3209                        );
3210                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3211                        let control_handle =
3212                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3213                        Ok(VirtioDeviceRequest::ConfigureQueue {
3214                            queue: req.queue,
3215                            size: req.size,
3216                            desc: req.desc,
3217                            avail: req.avail,
3218                            used: req.used,
3219
3220                            responder: VirtioDeviceConfigureQueueResponder {
3221                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3222                                tx_id: header.tx_id,
3223                            },
3224                        })
3225                    }
3226                    0x6e3a61d652499244 => {
3227                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3228                        let mut req = fidl::new_empty!(
3229                            VirtioDeviceNotifyQueueRequest,
3230                            fidl::encoding::DefaultFuchsiaResourceDialect
3231                        );
3232                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3233                        let control_handle =
3234                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3235                        Ok(VirtioDeviceRequest::NotifyQueue { queue: req.queue, control_handle })
3236                    }
3237                    0x45707654f5d23c3f => {
3238                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3239                        let mut req = fidl::new_empty!(
3240                            VirtioDeviceReadyRequest,
3241                            fidl::encoding::DefaultFuchsiaResourceDialect
3242                        );
3243                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
3244                        let control_handle =
3245                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3246                        Ok(VirtioDeviceRequest::Ready {
3247                            negotiated_features: req.negotiated_features,
3248
3249                            responder: VirtioDeviceReadyResponder {
3250                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3251                                tx_id: header.tx_id,
3252                            },
3253                        })
3254                    }
3255                    _ => Err(fidl::Error::UnknownOrdinal {
3256                        ordinal: header.ordinal,
3257                        protocol_name:
3258                            <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3259                    }),
3260                }))
3261            },
3262        )
3263    }
3264}
3265
3266#[derive(Debug)]
3267pub enum VirtioDeviceRequest {
3268    /// Configure a `queue` for the device. This specifies the `size` and the
3269    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3270    ConfigureQueue {
3271        queue: u16,
3272        size: u16,
3273        desc: u64,
3274        avail: u64,
3275        used: u64,
3276        responder: VirtioDeviceConfigureQueueResponder,
3277    },
3278    /// Notify a `queue` for the device. Primarily used for black-box testing.
3279    NotifyQueue { queue: u16, control_handle: VirtioDeviceControlHandle },
3280    /// Ready a device. This provides the set of `negotiated_features` that the
3281    /// driver and device have agreed upon.
3282    Ready { negotiated_features: u32, responder: VirtioDeviceReadyResponder },
3283}
3284
3285impl VirtioDeviceRequest {
3286    #[allow(irrefutable_let_patterns)]
3287    pub fn into_configure_queue(
3288        self,
3289    ) -> Option<(u16, u16, u64, u64, u64, VirtioDeviceConfigureQueueResponder)> {
3290        if let VirtioDeviceRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
3291            self
3292        {
3293            Some((queue, size, desc, avail, used, responder))
3294        } else {
3295            None
3296        }
3297    }
3298
3299    #[allow(irrefutable_let_patterns)]
3300    pub fn into_notify_queue(self) -> Option<(u16, VirtioDeviceControlHandle)> {
3301        if let VirtioDeviceRequest::NotifyQueue { queue, control_handle } = self {
3302            Some((queue, control_handle))
3303        } else {
3304            None
3305        }
3306    }
3307
3308    #[allow(irrefutable_let_patterns)]
3309    pub fn into_ready(self) -> Option<(u32, VirtioDeviceReadyResponder)> {
3310        if let VirtioDeviceRequest::Ready { negotiated_features, responder } = self {
3311            Some((negotiated_features, responder))
3312        } else {
3313            None
3314        }
3315    }
3316
3317    /// Name of the method defined in FIDL
3318    pub fn method_name(&self) -> &'static str {
3319        match *self {
3320            VirtioDeviceRequest::ConfigureQueue { .. } => "configure_queue",
3321            VirtioDeviceRequest::NotifyQueue { .. } => "notify_queue",
3322            VirtioDeviceRequest::Ready { .. } => "ready",
3323        }
3324    }
3325}
3326
3327#[derive(Debug, Clone)]
3328pub struct VirtioDeviceControlHandle {
3329    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3330}
3331
3332impl fidl::endpoints::ControlHandle for VirtioDeviceControlHandle {
3333    fn shutdown(&self) {
3334        self.inner.shutdown()
3335    }
3336    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3337        self.inner.shutdown_with_epitaph(status)
3338    }
3339
3340    fn is_closed(&self) -> bool {
3341        self.inner.channel().is_closed()
3342    }
3343    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3344        self.inner.channel().on_closed()
3345    }
3346
3347    #[cfg(target_os = "fuchsia")]
3348    fn signal_peer(
3349        &self,
3350        clear_mask: zx::Signals,
3351        set_mask: zx::Signals,
3352    ) -> Result<(), zx_status::Status> {
3353        use fidl::Peered;
3354        self.inner.channel().signal_peer(clear_mask, set_mask)
3355    }
3356}
3357
3358impl VirtioDeviceControlHandle {}
3359
3360#[must_use = "FIDL methods require a response to be sent"]
3361#[derive(Debug)]
3362pub struct VirtioDeviceConfigureQueueResponder {
3363    control_handle: std::mem::ManuallyDrop<VirtioDeviceControlHandle>,
3364    tx_id: u32,
3365}
3366
3367/// Set the the channel to be shutdown (see [`VirtioDeviceControlHandle::shutdown`])
3368/// if the responder is dropped without sending a response, so that the client
3369/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3370impl std::ops::Drop for VirtioDeviceConfigureQueueResponder {
3371    fn drop(&mut self) {
3372        self.control_handle.shutdown();
3373        // Safety: drops once, never accessed again
3374        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3375    }
3376}
3377
3378impl fidl::endpoints::Responder for VirtioDeviceConfigureQueueResponder {
3379    type ControlHandle = VirtioDeviceControlHandle;
3380
3381    fn control_handle(&self) -> &VirtioDeviceControlHandle {
3382        &self.control_handle
3383    }
3384
3385    fn drop_without_shutdown(mut self) {
3386        // Safety: drops once, never accessed again due to mem::forget
3387        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3388        // Prevent Drop from running (which would shut down the channel)
3389        std::mem::forget(self);
3390    }
3391}
3392
3393impl VirtioDeviceConfigureQueueResponder {
3394    /// Sends a response to the FIDL transaction.
3395    ///
3396    /// Sets the channel to shutdown if an error occurs.
3397    pub fn send(self) -> Result<(), fidl::Error> {
3398        let _result = self.send_raw();
3399        if _result.is_err() {
3400            self.control_handle.shutdown();
3401        }
3402        self.drop_without_shutdown();
3403        _result
3404    }
3405
3406    /// Similar to "send" but does not shutdown the channel if an error occurs.
3407    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3408        let _result = self.send_raw();
3409        self.drop_without_shutdown();
3410        _result
3411    }
3412
3413    fn send_raw(&self) -> Result<(), fidl::Error> {
3414        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3415            (),
3416            self.tx_id,
3417            0x72b44fb963480b11,
3418            fidl::encoding::DynamicFlags::empty(),
3419        )
3420    }
3421}
3422
3423#[must_use = "FIDL methods require a response to be sent"]
3424#[derive(Debug)]
3425pub struct VirtioDeviceReadyResponder {
3426    control_handle: std::mem::ManuallyDrop<VirtioDeviceControlHandle>,
3427    tx_id: u32,
3428}
3429
3430/// Set the the channel to be shutdown (see [`VirtioDeviceControlHandle::shutdown`])
3431/// if the responder is dropped without sending a response, so that the client
3432/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3433impl std::ops::Drop for VirtioDeviceReadyResponder {
3434    fn drop(&mut self) {
3435        self.control_handle.shutdown();
3436        // Safety: drops once, never accessed again
3437        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3438    }
3439}
3440
3441impl fidl::endpoints::Responder for VirtioDeviceReadyResponder {
3442    type ControlHandle = VirtioDeviceControlHandle;
3443
3444    fn control_handle(&self) -> &VirtioDeviceControlHandle {
3445        &self.control_handle
3446    }
3447
3448    fn drop_without_shutdown(mut self) {
3449        // Safety: drops once, never accessed again due to mem::forget
3450        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3451        // Prevent Drop from running (which would shut down the channel)
3452        std::mem::forget(self);
3453    }
3454}
3455
3456impl VirtioDeviceReadyResponder {
3457    /// Sends a response to the FIDL transaction.
3458    ///
3459    /// Sets the channel to shutdown if an error occurs.
3460    pub fn send(self) -> Result<(), fidl::Error> {
3461        let _result = self.send_raw();
3462        if _result.is_err() {
3463            self.control_handle.shutdown();
3464        }
3465        self.drop_without_shutdown();
3466        _result
3467    }
3468
3469    /// Similar to "send" but does not shutdown the channel if an error occurs.
3470    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3471        let _result = self.send_raw();
3472        self.drop_without_shutdown();
3473        _result
3474    }
3475
3476    fn send_raw(&self) -> Result<(), fidl::Error> {
3477        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3478            (),
3479            self.tx_id,
3480            0x45707654f5d23c3f,
3481            fidl::encoding::DynamicFlags::empty(),
3482        )
3483    }
3484}
3485
3486#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3487pub struct VirtioGpuMarker;
3488
3489impl fidl::endpoints::ProtocolMarker for VirtioGpuMarker {
3490    type Proxy = VirtioGpuProxy;
3491    type RequestStream = VirtioGpuRequestStream;
3492    #[cfg(target_os = "fuchsia")]
3493    type SynchronousProxy = VirtioGpuSynchronousProxy;
3494
3495    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioGpu";
3496}
3497impl fidl::endpoints::DiscoverableProtocolMarker for VirtioGpuMarker {}
3498
3499pub trait VirtioGpuProxyInterface: Send + Sync {
3500    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3501    fn r#configure_queue(
3502        &self,
3503        queue: u16,
3504        size: u16,
3505        desc: u64,
3506        avail: u64,
3507        used: u64,
3508    ) -> Self::ConfigureQueueResponseFut;
3509    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
3510    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3511    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
3512    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3513    fn r#start(
3514        &self,
3515        start_info: StartInfo,
3516        keyboard_listener: Option<
3517            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3518        >,
3519        mouse_source: Option<
3520            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3521        >,
3522    ) -> Self::StartResponseFut;
3523}
3524#[derive(Debug)]
3525#[cfg(target_os = "fuchsia")]
3526pub struct VirtioGpuSynchronousProxy {
3527    client: fidl::client::sync::Client,
3528}
3529
3530#[cfg(target_os = "fuchsia")]
3531impl fidl::endpoints::SynchronousProxy for VirtioGpuSynchronousProxy {
3532    type Proxy = VirtioGpuProxy;
3533    type Protocol = VirtioGpuMarker;
3534
3535    fn from_channel(inner: fidl::Channel) -> Self {
3536        Self::new(inner)
3537    }
3538
3539    fn into_channel(self) -> fidl::Channel {
3540        self.client.into_channel()
3541    }
3542
3543    fn as_channel(&self) -> &fidl::Channel {
3544        self.client.as_channel()
3545    }
3546}
3547
3548#[cfg(target_os = "fuchsia")]
3549impl VirtioGpuSynchronousProxy {
3550    pub fn new(channel: fidl::Channel) -> Self {
3551        let protocol_name = <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3552        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3553    }
3554
3555    pub fn into_channel(self) -> fidl::Channel {
3556        self.client.into_channel()
3557    }
3558
3559    /// Waits until an event arrives and returns it. It is safe for other
3560    /// threads to make concurrent requests while waiting for an event.
3561    pub fn wait_for_event(
3562        &self,
3563        deadline: zx::MonotonicInstant,
3564    ) -> Result<VirtioGpuEvent, fidl::Error> {
3565        VirtioGpuEvent::decode(self.client.wait_for_event(deadline)?)
3566    }
3567
3568    /// Configure a `queue` for the device. This specifies the `size` and the
3569    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3570    pub fn r#configure_queue(
3571        &self,
3572        mut queue: u16,
3573        mut size: u16,
3574        mut desc: u64,
3575        mut avail: u64,
3576        mut used: u64,
3577        ___deadline: zx::MonotonicInstant,
3578    ) -> Result<(), fidl::Error> {
3579        let _response = self
3580            .client
3581            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
3582                (queue, size, desc, avail, used),
3583                0x72b44fb963480b11,
3584                fidl::encoding::DynamicFlags::empty(),
3585                ___deadline,
3586            )?;
3587        Ok(_response)
3588    }
3589
3590    /// Notify a `queue` for the device. Primarily used for black-box testing.
3591    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3592        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3593            (queue,),
3594            0x6e3a61d652499244,
3595            fidl::encoding::DynamicFlags::empty(),
3596        )
3597    }
3598
3599    /// Ready a device. This provides the set of `negotiated_features` that the
3600    /// driver and device have agreed upon.
3601    pub fn r#ready(
3602        &self,
3603        mut negotiated_features: u32,
3604        ___deadline: zx::MonotonicInstant,
3605    ) -> Result<(), fidl::Error> {
3606        let _response =
3607            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
3608                (negotiated_features,),
3609                0x45707654f5d23c3f,
3610                fidl::encoding::DynamicFlags::empty(),
3611                ___deadline,
3612            )?;
3613        Ok(_response)
3614    }
3615
3616    /// Start the GPU device.
3617    pub fn r#start(
3618        &self,
3619        mut start_info: StartInfo,
3620        mut keyboard_listener: Option<
3621            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3622        >,
3623        mut mouse_source: Option<
3624            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3625        >,
3626        ___deadline: zx::MonotonicInstant,
3627    ) -> Result<(), fidl::Error> {
3628        let _response =
3629            self.client.send_query::<VirtioGpuStartRequest, fidl::encoding::EmptyPayload>(
3630                (&mut start_info, keyboard_listener, mouse_source),
3631                0x7e81ed410f770c14,
3632                fidl::encoding::DynamicFlags::empty(),
3633                ___deadline,
3634            )?;
3635        Ok(_response)
3636    }
3637}
3638
3639#[cfg(target_os = "fuchsia")]
3640impl From<VirtioGpuSynchronousProxy> for zx::Handle {
3641    fn from(value: VirtioGpuSynchronousProxy) -> Self {
3642        value.into_channel().into()
3643    }
3644}
3645
3646#[cfg(target_os = "fuchsia")]
3647impl From<fidl::Channel> for VirtioGpuSynchronousProxy {
3648    fn from(value: fidl::Channel) -> Self {
3649        Self::new(value)
3650    }
3651}
3652
3653#[derive(Debug, Clone)]
3654pub struct VirtioGpuProxy {
3655    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3656}
3657
3658impl fidl::endpoints::Proxy for VirtioGpuProxy {
3659    type Protocol = VirtioGpuMarker;
3660
3661    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3662        Self::new(inner)
3663    }
3664
3665    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3666        self.client.into_channel().map_err(|client| Self { client })
3667    }
3668
3669    fn as_channel(&self) -> &::fidl::AsyncChannel {
3670        self.client.as_channel()
3671    }
3672}
3673
3674impl VirtioGpuProxy {
3675    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioGpu.
3676    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3677        let protocol_name = <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3678        Self { client: fidl::client::Client::new(channel, protocol_name) }
3679    }
3680
3681    /// Get a Stream of events from the remote end of the protocol.
3682    ///
3683    /// # Panics
3684    ///
3685    /// Panics if the event stream was already taken.
3686    pub fn take_event_stream(&self) -> VirtioGpuEventStream {
3687        VirtioGpuEventStream { event_receiver: self.client.take_event_receiver() }
3688    }
3689
3690    /// Configure a `queue` for the device. This specifies the `size` and the
3691    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3692    pub fn r#configure_queue(
3693        &self,
3694        mut queue: u16,
3695        mut size: u16,
3696        mut desc: u64,
3697        mut avail: u64,
3698        mut used: u64,
3699    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3700        VirtioGpuProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
3701    }
3702
3703    /// Notify a `queue` for the device. Primarily used for black-box testing.
3704    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3705        VirtioGpuProxyInterface::r#notify_queue(self, queue)
3706    }
3707
3708    /// Ready a device. This provides the set of `negotiated_features` that the
3709    /// driver and device have agreed upon.
3710    pub fn r#ready(
3711        &self,
3712        mut negotiated_features: u32,
3713    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3714        VirtioGpuProxyInterface::r#ready(self, negotiated_features)
3715    }
3716
3717    /// Start the GPU device.
3718    pub fn r#start(
3719        &self,
3720        mut start_info: StartInfo,
3721        mut keyboard_listener: Option<
3722            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3723        >,
3724        mut mouse_source: Option<
3725            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3726        >,
3727    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3728        VirtioGpuProxyInterface::r#start(self, start_info, keyboard_listener, mouse_source)
3729    }
3730}
3731
3732impl VirtioGpuProxyInterface for VirtioGpuProxy {
3733    type ConfigureQueueResponseFut =
3734        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3735    fn r#configure_queue(
3736        &self,
3737        mut queue: u16,
3738        mut size: u16,
3739        mut desc: u64,
3740        mut avail: u64,
3741        mut used: u64,
3742    ) -> Self::ConfigureQueueResponseFut {
3743        fn _decode(
3744            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3745        ) -> Result<(), fidl::Error> {
3746            let _response = fidl::client::decode_transaction_body::<
3747                fidl::encoding::EmptyPayload,
3748                fidl::encoding::DefaultFuchsiaResourceDialect,
3749                0x72b44fb963480b11,
3750            >(_buf?)?;
3751            Ok(_response)
3752        }
3753        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
3754            (queue, size, desc, avail, used),
3755            0x72b44fb963480b11,
3756            fidl::encoding::DynamicFlags::empty(),
3757            _decode,
3758        )
3759    }
3760
3761    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3762        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3763            (queue,),
3764            0x6e3a61d652499244,
3765            fidl::encoding::DynamicFlags::empty(),
3766        )
3767    }
3768
3769    type ReadyResponseFut =
3770        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3771    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
3772        fn _decode(
3773            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3774        ) -> Result<(), fidl::Error> {
3775            let _response = fidl::client::decode_transaction_body::<
3776                fidl::encoding::EmptyPayload,
3777                fidl::encoding::DefaultFuchsiaResourceDialect,
3778                0x45707654f5d23c3f,
3779            >(_buf?)?;
3780            Ok(_response)
3781        }
3782        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
3783            (negotiated_features,),
3784            0x45707654f5d23c3f,
3785            fidl::encoding::DynamicFlags::empty(),
3786            _decode,
3787        )
3788    }
3789
3790    type StartResponseFut =
3791        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3792    fn r#start(
3793        &self,
3794        mut start_info: StartInfo,
3795        mut keyboard_listener: Option<
3796            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3797        >,
3798        mut mouse_source: Option<
3799            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3800        >,
3801    ) -> Self::StartResponseFut {
3802        fn _decode(
3803            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3804        ) -> Result<(), fidl::Error> {
3805            let _response = fidl::client::decode_transaction_body::<
3806                fidl::encoding::EmptyPayload,
3807                fidl::encoding::DefaultFuchsiaResourceDialect,
3808                0x7e81ed410f770c14,
3809            >(_buf?)?;
3810            Ok(_response)
3811        }
3812        self.client.send_query_and_decode::<VirtioGpuStartRequest, ()>(
3813            (&mut start_info, keyboard_listener, mouse_source),
3814            0x7e81ed410f770c14,
3815            fidl::encoding::DynamicFlags::empty(),
3816            _decode,
3817        )
3818    }
3819}
3820
3821pub struct VirtioGpuEventStream {
3822    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3823}
3824
3825impl std::marker::Unpin for VirtioGpuEventStream {}
3826
3827impl futures::stream::FusedStream for VirtioGpuEventStream {
3828    fn is_terminated(&self) -> bool {
3829        self.event_receiver.is_terminated()
3830    }
3831}
3832
3833impl futures::Stream for VirtioGpuEventStream {
3834    type Item = Result<VirtioGpuEvent, fidl::Error>;
3835
3836    fn poll_next(
3837        mut self: std::pin::Pin<&mut Self>,
3838        cx: &mut std::task::Context<'_>,
3839    ) -> std::task::Poll<Option<Self::Item>> {
3840        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3841            &mut self.event_receiver,
3842            cx
3843        )?) {
3844            Some(buf) => std::task::Poll::Ready(Some(VirtioGpuEvent::decode(buf))),
3845            None => std::task::Poll::Ready(None),
3846        }
3847    }
3848}
3849
3850#[derive(Debug)]
3851pub enum VirtioGpuEvent {
3852    OnConfigChanged {},
3853}
3854
3855impl VirtioGpuEvent {
3856    #[allow(irrefutable_let_patterns)]
3857    pub fn into_on_config_changed(self) -> Option<()> {
3858        if let VirtioGpuEvent::OnConfigChanged {} = self {
3859            Some(())
3860        } else {
3861            None
3862        }
3863    }
3864
3865    /// Decodes a message buffer as a [`VirtioGpuEvent`].
3866    fn decode(
3867        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3868    ) -> Result<VirtioGpuEvent, fidl::Error> {
3869        let (bytes, _handles) = buf.split_mut();
3870        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3871        debug_assert_eq!(tx_header.tx_id, 0);
3872        match tx_header.ordinal {
3873            0x1555f5b7c8444aa0 => {
3874                let mut out = fidl::new_empty!(
3875                    fidl::encoding::EmptyPayload,
3876                    fidl::encoding::DefaultFuchsiaResourceDialect
3877                );
3878                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3879                Ok((VirtioGpuEvent::OnConfigChanged {}))
3880            }
3881            _ => Err(fidl::Error::UnknownOrdinal {
3882                ordinal: tx_header.ordinal,
3883                protocol_name: <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3884            }),
3885        }
3886    }
3887}
3888
3889/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioGpu.
3890pub struct VirtioGpuRequestStream {
3891    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3892    is_terminated: bool,
3893}
3894
3895impl std::marker::Unpin for VirtioGpuRequestStream {}
3896
3897impl futures::stream::FusedStream for VirtioGpuRequestStream {
3898    fn is_terminated(&self) -> bool {
3899        self.is_terminated
3900    }
3901}
3902
3903impl fidl::endpoints::RequestStream for VirtioGpuRequestStream {
3904    type Protocol = VirtioGpuMarker;
3905    type ControlHandle = VirtioGpuControlHandle;
3906
3907    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3908        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3909    }
3910
3911    fn control_handle(&self) -> Self::ControlHandle {
3912        VirtioGpuControlHandle { inner: self.inner.clone() }
3913    }
3914
3915    fn into_inner(
3916        self,
3917    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3918    {
3919        (self.inner, self.is_terminated)
3920    }
3921
3922    fn from_inner(
3923        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3924        is_terminated: bool,
3925    ) -> Self {
3926        Self { inner, is_terminated }
3927    }
3928}
3929
3930impl futures::Stream for VirtioGpuRequestStream {
3931    type Item = Result<VirtioGpuRequest, fidl::Error>;
3932
3933    fn poll_next(
3934        mut self: std::pin::Pin<&mut Self>,
3935        cx: &mut std::task::Context<'_>,
3936    ) -> std::task::Poll<Option<Self::Item>> {
3937        let this = &mut *self;
3938        if this.inner.check_shutdown(cx) {
3939            this.is_terminated = true;
3940            return std::task::Poll::Ready(None);
3941        }
3942        if this.is_terminated {
3943            panic!("polled VirtioGpuRequestStream after completion");
3944        }
3945        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3946            |bytes, handles| {
3947                match this.inner.channel().read_etc(cx, bytes, handles) {
3948                    std::task::Poll::Ready(Ok(())) => {}
3949                    std::task::Poll::Pending => return std::task::Poll::Pending,
3950                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3951                        this.is_terminated = true;
3952                        return std::task::Poll::Ready(None);
3953                    }
3954                    std::task::Poll::Ready(Err(e)) => {
3955                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3956                            e.into(),
3957                        ))))
3958                    }
3959                }
3960
3961                // A message has been received from the channel
3962                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3963
3964                std::task::Poll::Ready(Some(match header.ordinal {
3965                    0x72b44fb963480b11 => {
3966                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3967                        let mut req = fidl::new_empty!(
3968                            VirtioDeviceConfigureQueueRequest,
3969                            fidl::encoding::DefaultFuchsiaResourceDialect
3970                        );
3971                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3972                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
3973                        Ok(VirtioGpuRequest::ConfigureQueue {
3974                            queue: req.queue,
3975                            size: req.size,
3976                            desc: req.desc,
3977                            avail: req.avail,
3978                            used: req.used,
3979
3980                            responder: VirtioGpuConfigureQueueResponder {
3981                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3982                                tx_id: header.tx_id,
3983                            },
3984                        })
3985                    }
3986                    0x6e3a61d652499244 => {
3987                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3988                        let mut req = fidl::new_empty!(
3989                            VirtioDeviceNotifyQueueRequest,
3990                            fidl::encoding::DefaultFuchsiaResourceDialect
3991                        );
3992                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3993                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
3994                        Ok(VirtioGpuRequest::NotifyQueue { queue: req.queue, control_handle })
3995                    }
3996                    0x45707654f5d23c3f => {
3997                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3998                        let mut req = fidl::new_empty!(
3999                            VirtioDeviceReadyRequest,
4000                            fidl::encoding::DefaultFuchsiaResourceDialect
4001                        );
4002                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
4003                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
4004                        Ok(VirtioGpuRequest::Ready {
4005                            negotiated_features: req.negotiated_features,
4006
4007                            responder: VirtioGpuReadyResponder {
4008                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4009                                tx_id: header.tx_id,
4010                            },
4011                        })
4012                    }
4013                    0x7e81ed410f770c14 => {
4014                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4015                        let mut req = fidl::new_empty!(
4016                            VirtioGpuStartRequest,
4017                            fidl::encoding::DefaultFuchsiaResourceDialect
4018                        );
4019                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioGpuStartRequest>(&header, _body_bytes, handles, &mut req)?;
4020                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
4021                        Ok(VirtioGpuRequest::Start {
4022                            start_info: req.start_info,
4023                            keyboard_listener: req.keyboard_listener,
4024                            mouse_source: req.mouse_source,
4025
4026                            responder: VirtioGpuStartResponder {
4027                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4028                                tx_id: header.tx_id,
4029                            },
4030                        })
4031                    }
4032                    _ => Err(fidl::Error::UnknownOrdinal {
4033                        ordinal: header.ordinal,
4034                        protocol_name:
4035                            <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4036                    }),
4037                }))
4038            },
4039        )
4040    }
4041}
4042
4043#[derive(Debug)]
4044pub enum VirtioGpuRequest {
4045    /// Configure a `queue` for the device. This specifies the `size` and the
4046    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4047    ConfigureQueue {
4048        queue: u16,
4049        size: u16,
4050        desc: u64,
4051        avail: u64,
4052        used: u64,
4053        responder: VirtioGpuConfigureQueueResponder,
4054    },
4055    /// Notify a `queue` for the device. Primarily used for black-box testing.
4056    NotifyQueue { queue: u16, control_handle: VirtioGpuControlHandle },
4057    /// Ready a device. This provides the set of `negotiated_features` that the
4058    /// driver and device have agreed upon.
4059    Ready { negotiated_features: u32, responder: VirtioGpuReadyResponder },
4060    /// Start the GPU device.
4061    Start {
4062        start_info: StartInfo,
4063        keyboard_listener:
4064            Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
4065        mouse_source:
4066            Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
4067        responder: VirtioGpuStartResponder,
4068    },
4069}
4070
4071impl VirtioGpuRequest {
4072    #[allow(irrefutable_let_patterns)]
4073    pub fn into_configure_queue(
4074        self,
4075    ) -> Option<(u16, u16, u64, u64, u64, VirtioGpuConfigureQueueResponder)> {
4076        if let VirtioGpuRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
4077        {
4078            Some((queue, size, desc, avail, used, responder))
4079        } else {
4080            None
4081        }
4082    }
4083
4084    #[allow(irrefutable_let_patterns)]
4085    pub fn into_notify_queue(self) -> Option<(u16, VirtioGpuControlHandle)> {
4086        if let VirtioGpuRequest::NotifyQueue { queue, control_handle } = self {
4087            Some((queue, control_handle))
4088        } else {
4089            None
4090        }
4091    }
4092
4093    #[allow(irrefutable_let_patterns)]
4094    pub fn into_ready(self) -> Option<(u32, VirtioGpuReadyResponder)> {
4095        if let VirtioGpuRequest::Ready { negotiated_features, responder } = self {
4096            Some((negotiated_features, responder))
4097        } else {
4098            None
4099        }
4100    }
4101
4102    #[allow(irrefutable_let_patterns)]
4103    pub fn into_start(
4104        self,
4105    ) -> Option<(
4106        StartInfo,
4107        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
4108        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
4109        VirtioGpuStartResponder,
4110    )> {
4111        if let VirtioGpuRequest::Start { start_info, keyboard_listener, mouse_source, responder } =
4112            self
4113        {
4114            Some((start_info, keyboard_listener, mouse_source, responder))
4115        } else {
4116            None
4117        }
4118    }
4119
4120    /// Name of the method defined in FIDL
4121    pub fn method_name(&self) -> &'static str {
4122        match *self {
4123            VirtioGpuRequest::ConfigureQueue { .. } => "configure_queue",
4124            VirtioGpuRequest::NotifyQueue { .. } => "notify_queue",
4125            VirtioGpuRequest::Ready { .. } => "ready",
4126            VirtioGpuRequest::Start { .. } => "start",
4127        }
4128    }
4129}
4130
4131#[derive(Debug, Clone)]
4132pub struct VirtioGpuControlHandle {
4133    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4134}
4135
4136impl fidl::endpoints::ControlHandle for VirtioGpuControlHandle {
4137    fn shutdown(&self) {
4138        self.inner.shutdown()
4139    }
4140    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4141        self.inner.shutdown_with_epitaph(status)
4142    }
4143
4144    fn is_closed(&self) -> bool {
4145        self.inner.channel().is_closed()
4146    }
4147    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4148        self.inner.channel().on_closed()
4149    }
4150
4151    #[cfg(target_os = "fuchsia")]
4152    fn signal_peer(
4153        &self,
4154        clear_mask: zx::Signals,
4155        set_mask: zx::Signals,
4156    ) -> Result<(), zx_status::Status> {
4157        use fidl::Peered;
4158        self.inner.channel().signal_peer(clear_mask, set_mask)
4159    }
4160}
4161
4162impl VirtioGpuControlHandle {
4163    pub fn send_on_config_changed(&self) -> Result<(), fidl::Error> {
4164        self.inner.send::<fidl::encoding::EmptyPayload>(
4165            (),
4166            0,
4167            0x1555f5b7c8444aa0,
4168            fidl::encoding::DynamicFlags::empty(),
4169        )
4170    }
4171}
4172
4173#[must_use = "FIDL methods require a response to be sent"]
4174#[derive(Debug)]
4175pub struct VirtioGpuConfigureQueueResponder {
4176    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4177    tx_id: u32,
4178}
4179
4180/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4181/// if the responder is dropped without sending a response, so that the client
4182/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4183impl std::ops::Drop for VirtioGpuConfigureQueueResponder {
4184    fn drop(&mut self) {
4185        self.control_handle.shutdown();
4186        // Safety: drops once, never accessed again
4187        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4188    }
4189}
4190
4191impl fidl::endpoints::Responder for VirtioGpuConfigureQueueResponder {
4192    type ControlHandle = VirtioGpuControlHandle;
4193
4194    fn control_handle(&self) -> &VirtioGpuControlHandle {
4195        &self.control_handle
4196    }
4197
4198    fn drop_without_shutdown(mut self) {
4199        // Safety: drops once, never accessed again due to mem::forget
4200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4201        // Prevent Drop from running (which would shut down the channel)
4202        std::mem::forget(self);
4203    }
4204}
4205
4206impl VirtioGpuConfigureQueueResponder {
4207    /// Sends a response to the FIDL transaction.
4208    ///
4209    /// Sets the channel to shutdown if an error occurs.
4210    pub fn send(self) -> Result<(), fidl::Error> {
4211        let _result = self.send_raw();
4212        if _result.is_err() {
4213            self.control_handle.shutdown();
4214        }
4215        self.drop_without_shutdown();
4216        _result
4217    }
4218
4219    /// Similar to "send" but does not shutdown the channel if an error occurs.
4220    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4221        let _result = self.send_raw();
4222        self.drop_without_shutdown();
4223        _result
4224    }
4225
4226    fn send_raw(&self) -> Result<(), fidl::Error> {
4227        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4228            (),
4229            self.tx_id,
4230            0x72b44fb963480b11,
4231            fidl::encoding::DynamicFlags::empty(),
4232        )
4233    }
4234}
4235
4236#[must_use = "FIDL methods require a response to be sent"]
4237#[derive(Debug)]
4238pub struct VirtioGpuReadyResponder {
4239    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4240    tx_id: u32,
4241}
4242
4243/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4244/// if the responder is dropped without sending a response, so that the client
4245/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4246impl std::ops::Drop for VirtioGpuReadyResponder {
4247    fn drop(&mut self) {
4248        self.control_handle.shutdown();
4249        // Safety: drops once, never accessed again
4250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4251    }
4252}
4253
4254impl fidl::endpoints::Responder for VirtioGpuReadyResponder {
4255    type ControlHandle = VirtioGpuControlHandle;
4256
4257    fn control_handle(&self) -> &VirtioGpuControlHandle {
4258        &self.control_handle
4259    }
4260
4261    fn drop_without_shutdown(mut self) {
4262        // Safety: drops once, never accessed again due to mem::forget
4263        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4264        // Prevent Drop from running (which would shut down the channel)
4265        std::mem::forget(self);
4266    }
4267}
4268
4269impl VirtioGpuReadyResponder {
4270    /// Sends a response to the FIDL transaction.
4271    ///
4272    /// Sets the channel to shutdown if an error occurs.
4273    pub fn send(self) -> Result<(), fidl::Error> {
4274        let _result = self.send_raw();
4275        if _result.is_err() {
4276            self.control_handle.shutdown();
4277        }
4278        self.drop_without_shutdown();
4279        _result
4280    }
4281
4282    /// Similar to "send" but does not shutdown the channel if an error occurs.
4283    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4284        let _result = self.send_raw();
4285        self.drop_without_shutdown();
4286        _result
4287    }
4288
4289    fn send_raw(&self) -> Result<(), fidl::Error> {
4290        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4291            (),
4292            self.tx_id,
4293            0x45707654f5d23c3f,
4294            fidl::encoding::DynamicFlags::empty(),
4295        )
4296    }
4297}
4298
4299#[must_use = "FIDL methods require a response to be sent"]
4300#[derive(Debug)]
4301pub struct VirtioGpuStartResponder {
4302    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4303    tx_id: u32,
4304}
4305
4306/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4307/// if the responder is dropped without sending a response, so that the client
4308/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4309impl std::ops::Drop for VirtioGpuStartResponder {
4310    fn drop(&mut self) {
4311        self.control_handle.shutdown();
4312        // Safety: drops once, never accessed again
4313        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4314    }
4315}
4316
4317impl fidl::endpoints::Responder for VirtioGpuStartResponder {
4318    type ControlHandle = VirtioGpuControlHandle;
4319
4320    fn control_handle(&self) -> &VirtioGpuControlHandle {
4321        &self.control_handle
4322    }
4323
4324    fn drop_without_shutdown(mut self) {
4325        // Safety: drops once, never accessed again due to mem::forget
4326        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4327        // Prevent Drop from running (which would shut down the channel)
4328        std::mem::forget(self);
4329    }
4330}
4331
4332impl VirtioGpuStartResponder {
4333    /// Sends a response to the FIDL transaction.
4334    ///
4335    /// Sets the channel to shutdown if an error occurs.
4336    pub fn send(self) -> Result<(), fidl::Error> {
4337        let _result = self.send_raw();
4338        if _result.is_err() {
4339            self.control_handle.shutdown();
4340        }
4341        self.drop_without_shutdown();
4342        _result
4343    }
4344
4345    /// Similar to "send" but does not shutdown the channel if an error occurs.
4346    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4347        let _result = self.send_raw();
4348        self.drop_without_shutdown();
4349        _result
4350    }
4351
4352    fn send_raw(&self) -> Result<(), fidl::Error> {
4353        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4354            (),
4355            self.tx_id,
4356            0x7e81ed410f770c14,
4357            fidl::encoding::DynamicFlags::empty(),
4358        )
4359    }
4360}
4361
4362#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4363pub struct VirtioInputMarker;
4364
4365impl fidl::endpoints::ProtocolMarker for VirtioInputMarker {
4366    type Proxy = VirtioInputProxy;
4367    type RequestStream = VirtioInputRequestStream;
4368    #[cfg(target_os = "fuchsia")]
4369    type SynchronousProxy = VirtioInputSynchronousProxy;
4370
4371    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioInput";
4372}
4373impl fidl::endpoints::DiscoverableProtocolMarker for VirtioInputMarker {}
4374
4375pub trait VirtioInputProxyInterface: Send + Sync {
4376    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4377    fn r#configure_queue(
4378        &self,
4379        queue: u16,
4380        size: u16,
4381        desc: u64,
4382        avail: u64,
4383        used: u64,
4384    ) -> Self::ConfigureQueueResponseFut;
4385    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
4386    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4387    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
4388    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4389    fn r#start(&self, start_info: StartInfo, input_type: InputType) -> Self::StartResponseFut;
4390}
4391#[derive(Debug)]
4392#[cfg(target_os = "fuchsia")]
4393pub struct VirtioInputSynchronousProxy {
4394    client: fidl::client::sync::Client,
4395}
4396
4397#[cfg(target_os = "fuchsia")]
4398impl fidl::endpoints::SynchronousProxy for VirtioInputSynchronousProxy {
4399    type Proxy = VirtioInputProxy;
4400    type Protocol = VirtioInputMarker;
4401
4402    fn from_channel(inner: fidl::Channel) -> Self {
4403        Self::new(inner)
4404    }
4405
4406    fn into_channel(self) -> fidl::Channel {
4407        self.client.into_channel()
4408    }
4409
4410    fn as_channel(&self) -> &fidl::Channel {
4411        self.client.as_channel()
4412    }
4413}
4414
4415#[cfg(target_os = "fuchsia")]
4416impl VirtioInputSynchronousProxy {
4417    pub fn new(channel: fidl::Channel) -> Self {
4418        let protocol_name = <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4419        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4420    }
4421
4422    pub fn into_channel(self) -> fidl::Channel {
4423        self.client.into_channel()
4424    }
4425
4426    /// Waits until an event arrives and returns it. It is safe for other
4427    /// threads to make concurrent requests while waiting for an event.
4428    pub fn wait_for_event(
4429        &self,
4430        deadline: zx::MonotonicInstant,
4431    ) -> Result<VirtioInputEvent, fidl::Error> {
4432        VirtioInputEvent::decode(self.client.wait_for_event(deadline)?)
4433    }
4434
4435    /// Configure a `queue` for the device. This specifies the `size` and the
4436    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4437    pub fn r#configure_queue(
4438        &self,
4439        mut queue: u16,
4440        mut size: u16,
4441        mut desc: u64,
4442        mut avail: u64,
4443        mut used: u64,
4444        ___deadline: zx::MonotonicInstant,
4445    ) -> Result<(), fidl::Error> {
4446        let _response = self
4447            .client
4448            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
4449                (queue, size, desc, avail, used),
4450                0x72b44fb963480b11,
4451                fidl::encoding::DynamicFlags::empty(),
4452                ___deadline,
4453            )?;
4454        Ok(_response)
4455    }
4456
4457    /// Notify a `queue` for the device. Primarily used for black-box testing.
4458    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4459        self.client.send::<VirtioDeviceNotifyQueueRequest>(
4460            (queue,),
4461            0x6e3a61d652499244,
4462            fidl::encoding::DynamicFlags::empty(),
4463        )
4464    }
4465
4466    /// Ready a device. This provides the set of `negotiated_features` that the
4467    /// driver and device have agreed upon.
4468    pub fn r#ready(
4469        &self,
4470        mut negotiated_features: u32,
4471        ___deadline: zx::MonotonicInstant,
4472    ) -> Result<(), fidl::Error> {
4473        let _response =
4474            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
4475                (negotiated_features,),
4476                0x45707654f5d23c3f,
4477                fidl::encoding::DynamicFlags::empty(),
4478                ___deadline,
4479            )?;
4480        Ok(_response)
4481    }
4482
4483    /// Start the input device.
4484    pub fn r#start(
4485        &self,
4486        mut start_info: StartInfo,
4487        mut input_type: InputType,
4488        ___deadline: zx::MonotonicInstant,
4489    ) -> Result<(), fidl::Error> {
4490        let _response =
4491            self.client.send_query::<VirtioInputStartRequest, fidl::encoding::EmptyPayload>(
4492                (&mut start_info, &mut input_type),
4493                0x612743931f7f9249,
4494                fidl::encoding::DynamicFlags::empty(),
4495                ___deadline,
4496            )?;
4497        Ok(_response)
4498    }
4499}
4500
4501#[cfg(target_os = "fuchsia")]
4502impl From<VirtioInputSynchronousProxy> for zx::Handle {
4503    fn from(value: VirtioInputSynchronousProxy) -> Self {
4504        value.into_channel().into()
4505    }
4506}
4507
4508#[cfg(target_os = "fuchsia")]
4509impl From<fidl::Channel> for VirtioInputSynchronousProxy {
4510    fn from(value: fidl::Channel) -> Self {
4511        Self::new(value)
4512    }
4513}
4514
4515#[derive(Debug, Clone)]
4516pub struct VirtioInputProxy {
4517    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4518}
4519
4520impl fidl::endpoints::Proxy for VirtioInputProxy {
4521    type Protocol = VirtioInputMarker;
4522
4523    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4524        Self::new(inner)
4525    }
4526
4527    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4528        self.client.into_channel().map_err(|client| Self { client })
4529    }
4530
4531    fn as_channel(&self) -> &::fidl::AsyncChannel {
4532        self.client.as_channel()
4533    }
4534}
4535
4536impl VirtioInputProxy {
4537    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioInput.
4538    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4539        let protocol_name = <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4540        Self { client: fidl::client::Client::new(channel, protocol_name) }
4541    }
4542
4543    /// Get a Stream of events from the remote end of the protocol.
4544    ///
4545    /// # Panics
4546    ///
4547    /// Panics if the event stream was already taken.
4548    pub fn take_event_stream(&self) -> VirtioInputEventStream {
4549        VirtioInputEventStream { event_receiver: self.client.take_event_receiver() }
4550    }
4551
4552    /// Configure a `queue` for the device. This specifies the `size` and the
4553    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4554    pub fn r#configure_queue(
4555        &self,
4556        mut queue: u16,
4557        mut size: u16,
4558        mut desc: u64,
4559        mut avail: u64,
4560        mut used: u64,
4561    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4562        VirtioInputProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
4563    }
4564
4565    /// Notify a `queue` for the device. Primarily used for black-box testing.
4566    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4567        VirtioInputProxyInterface::r#notify_queue(self, queue)
4568    }
4569
4570    /// Ready a device. This provides the set of `negotiated_features` that the
4571    /// driver and device have agreed upon.
4572    pub fn r#ready(
4573        &self,
4574        mut negotiated_features: u32,
4575    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4576        VirtioInputProxyInterface::r#ready(self, negotiated_features)
4577    }
4578
4579    /// Start the input device.
4580    pub fn r#start(
4581        &self,
4582        mut start_info: StartInfo,
4583        mut input_type: InputType,
4584    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4585        VirtioInputProxyInterface::r#start(self, start_info, input_type)
4586    }
4587}
4588
4589impl VirtioInputProxyInterface for VirtioInputProxy {
4590    type ConfigureQueueResponseFut =
4591        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4592    fn r#configure_queue(
4593        &self,
4594        mut queue: u16,
4595        mut size: u16,
4596        mut desc: u64,
4597        mut avail: u64,
4598        mut used: u64,
4599    ) -> Self::ConfigureQueueResponseFut {
4600        fn _decode(
4601            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4602        ) -> Result<(), fidl::Error> {
4603            let _response = fidl::client::decode_transaction_body::<
4604                fidl::encoding::EmptyPayload,
4605                fidl::encoding::DefaultFuchsiaResourceDialect,
4606                0x72b44fb963480b11,
4607            >(_buf?)?;
4608            Ok(_response)
4609        }
4610        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
4611            (queue, size, desc, avail, used),
4612            0x72b44fb963480b11,
4613            fidl::encoding::DynamicFlags::empty(),
4614            _decode,
4615        )
4616    }
4617
4618    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4619        self.client.send::<VirtioDeviceNotifyQueueRequest>(
4620            (queue,),
4621            0x6e3a61d652499244,
4622            fidl::encoding::DynamicFlags::empty(),
4623        )
4624    }
4625
4626    type ReadyResponseFut =
4627        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4628    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
4629        fn _decode(
4630            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4631        ) -> Result<(), fidl::Error> {
4632            let _response = fidl::client::decode_transaction_body::<
4633                fidl::encoding::EmptyPayload,
4634                fidl::encoding::DefaultFuchsiaResourceDialect,
4635                0x45707654f5d23c3f,
4636            >(_buf?)?;
4637            Ok(_response)
4638        }
4639        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
4640            (negotiated_features,),
4641            0x45707654f5d23c3f,
4642            fidl::encoding::DynamicFlags::empty(),
4643            _decode,
4644        )
4645    }
4646
4647    type StartResponseFut =
4648        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4649    fn r#start(
4650        &self,
4651        mut start_info: StartInfo,
4652        mut input_type: InputType,
4653    ) -> Self::StartResponseFut {
4654        fn _decode(
4655            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4656        ) -> Result<(), fidl::Error> {
4657            let _response = fidl::client::decode_transaction_body::<
4658                fidl::encoding::EmptyPayload,
4659                fidl::encoding::DefaultFuchsiaResourceDialect,
4660                0x612743931f7f9249,
4661            >(_buf?)?;
4662            Ok(_response)
4663        }
4664        self.client.send_query_and_decode::<VirtioInputStartRequest, ()>(
4665            (&mut start_info, &mut input_type),
4666            0x612743931f7f9249,
4667            fidl::encoding::DynamicFlags::empty(),
4668            _decode,
4669        )
4670    }
4671}
4672
4673pub struct VirtioInputEventStream {
4674    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4675}
4676
4677impl std::marker::Unpin for VirtioInputEventStream {}
4678
4679impl futures::stream::FusedStream for VirtioInputEventStream {
4680    fn is_terminated(&self) -> bool {
4681        self.event_receiver.is_terminated()
4682    }
4683}
4684
4685impl futures::Stream for VirtioInputEventStream {
4686    type Item = Result<VirtioInputEvent, fidl::Error>;
4687
4688    fn poll_next(
4689        mut self: std::pin::Pin<&mut Self>,
4690        cx: &mut std::task::Context<'_>,
4691    ) -> std::task::Poll<Option<Self::Item>> {
4692        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4693            &mut self.event_receiver,
4694            cx
4695        )?) {
4696            Some(buf) => std::task::Poll::Ready(Some(VirtioInputEvent::decode(buf))),
4697            None => std::task::Poll::Ready(None),
4698        }
4699    }
4700}
4701
4702#[derive(Debug)]
4703pub enum VirtioInputEvent {}
4704
4705impl VirtioInputEvent {
4706    /// Decodes a message buffer as a [`VirtioInputEvent`].
4707    fn decode(
4708        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4709    ) -> Result<VirtioInputEvent, fidl::Error> {
4710        let (bytes, _handles) = buf.split_mut();
4711        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4712        debug_assert_eq!(tx_header.tx_id, 0);
4713        match tx_header.ordinal {
4714            _ => Err(fidl::Error::UnknownOrdinal {
4715                ordinal: tx_header.ordinal,
4716                protocol_name: <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4717            }),
4718        }
4719    }
4720}
4721
4722/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioInput.
4723pub struct VirtioInputRequestStream {
4724    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4725    is_terminated: bool,
4726}
4727
4728impl std::marker::Unpin for VirtioInputRequestStream {}
4729
4730impl futures::stream::FusedStream for VirtioInputRequestStream {
4731    fn is_terminated(&self) -> bool {
4732        self.is_terminated
4733    }
4734}
4735
4736impl fidl::endpoints::RequestStream for VirtioInputRequestStream {
4737    type Protocol = VirtioInputMarker;
4738    type ControlHandle = VirtioInputControlHandle;
4739
4740    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4741        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4742    }
4743
4744    fn control_handle(&self) -> Self::ControlHandle {
4745        VirtioInputControlHandle { inner: self.inner.clone() }
4746    }
4747
4748    fn into_inner(
4749        self,
4750    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4751    {
4752        (self.inner, self.is_terminated)
4753    }
4754
4755    fn from_inner(
4756        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4757        is_terminated: bool,
4758    ) -> Self {
4759        Self { inner, is_terminated }
4760    }
4761}
4762
4763impl futures::Stream for VirtioInputRequestStream {
4764    type Item = Result<VirtioInputRequest, fidl::Error>;
4765
4766    fn poll_next(
4767        mut self: std::pin::Pin<&mut Self>,
4768        cx: &mut std::task::Context<'_>,
4769    ) -> std::task::Poll<Option<Self::Item>> {
4770        let this = &mut *self;
4771        if this.inner.check_shutdown(cx) {
4772            this.is_terminated = true;
4773            return std::task::Poll::Ready(None);
4774        }
4775        if this.is_terminated {
4776            panic!("polled VirtioInputRequestStream after completion");
4777        }
4778        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4779            |bytes, handles| {
4780                match this.inner.channel().read_etc(cx, bytes, handles) {
4781                    std::task::Poll::Ready(Ok(())) => {}
4782                    std::task::Poll::Pending => return std::task::Poll::Pending,
4783                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4784                        this.is_terminated = true;
4785                        return std::task::Poll::Ready(None);
4786                    }
4787                    std::task::Poll::Ready(Err(e)) => {
4788                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4789                            e.into(),
4790                        ))))
4791                    }
4792                }
4793
4794                // A message has been received from the channel
4795                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4796
4797                std::task::Poll::Ready(Some(match header.ordinal {
4798                    0x72b44fb963480b11 => {
4799                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4800                        let mut req = fidl::new_empty!(
4801                            VirtioDeviceConfigureQueueRequest,
4802                            fidl::encoding::DefaultFuchsiaResourceDialect
4803                        );
4804                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
4805                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4806                        Ok(VirtioInputRequest::ConfigureQueue {
4807                            queue: req.queue,
4808                            size: req.size,
4809                            desc: req.desc,
4810                            avail: req.avail,
4811                            used: req.used,
4812
4813                            responder: VirtioInputConfigureQueueResponder {
4814                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4815                                tx_id: header.tx_id,
4816                            },
4817                        })
4818                    }
4819                    0x6e3a61d652499244 => {
4820                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4821                        let mut req = fidl::new_empty!(
4822                            VirtioDeviceNotifyQueueRequest,
4823                            fidl::encoding::DefaultFuchsiaResourceDialect
4824                        );
4825                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
4826                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4827                        Ok(VirtioInputRequest::NotifyQueue { queue: req.queue, control_handle })
4828                    }
4829                    0x45707654f5d23c3f => {
4830                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4831                        let mut req = fidl::new_empty!(
4832                            VirtioDeviceReadyRequest,
4833                            fidl::encoding::DefaultFuchsiaResourceDialect
4834                        );
4835                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
4836                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4837                        Ok(VirtioInputRequest::Ready {
4838                            negotiated_features: req.negotiated_features,
4839
4840                            responder: VirtioInputReadyResponder {
4841                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4842                                tx_id: header.tx_id,
4843                            },
4844                        })
4845                    }
4846                    0x612743931f7f9249 => {
4847                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4848                        let mut req = fidl::new_empty!(
4849                            VirtioInputStartRequest,
4850                            fidl::encoding::DefaultFuchsiaResourceDialect
4851                        );
4852                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioInputStartRequest>(&header, _body_bytes, handles, &mut req)?;
4853                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4854                        Ok(VirtioInputRequest::Start {
4855                            start_info: req.start_info,
4856                            input_type: req.input_type,
4857
4858                            responder: VirtioInputStartResponder {
4859                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4860                                tx_id: header.tx_id,
4861                            },
4862                        })
4863                    }
4864                    _ => Err(fidl::Error::UnknownOrdinal {
4865                        ordinal: header.ordinal,
4866                        protocol_name:
4867                            <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4868                    }),
4869                }))
4870            },
4871        )
4872    }
4873}
4874
4875#[derive(Debug)]
4876pub enum VirtioInputRequest {
4877    /// Configure a `queue` for the device. This specifies the `size` and the
4878    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4879    ConfigureQueue {
4880        queue: u16,
4881        size: u16,
4882        desc: u64,
4883        avail: u64,
4884        used: u64,
4885        responder: VirtioInputConfigureQueueResponder,
4886    },
4887    /// Notify a `queue` for the device. Primarily used for black-box testing.
4888    NotifyQueue { queue: u16, control_handle: VirtioInputControlHandle },
4889    /// Ready a device. This provides the set of `negotiated_features` that the
4890    /// driver and device have agreed upon.
4891    Ready { negotiated_features: u32, responder: VirtioInputReadyResponder },
4892    /// Start the input device.
4893    Start { start_info: StartInfo, input_type: InputType, responder: VirtioInputStartResponder },
4894}
4895
4896impl VirtioInputRequest {
4897    #[allow(irrefutable_let_patterns)]
4898    pub fn into_configure_queue(
4899        self,
4900    ) -> Option<(u16, u16, u64, u64, u64, VirtioInputConfigureQueueResponder)> {
4901        if let VirtioInputRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
4902            self
4903        {
4904            Some((queue, size, desc, avail, used, responder))
4905        } else {
4906            None
4907        }
4908    }
4909
4910    #[allow(irrefutable_let_patterns)]
4911    pub fn into_notify_queue(self) -> Option<(u16, VirtioInputControlHandle)> {
4912        if let VirtioInputRequest::NotifyQueue { queue, control_handle } = self {
4913            Some((queue, control_handle))
4914        } else {
4915            None
4916        }
4917    }
4918
4919    #[allow(irrefutable_let_patterns)]
4920    pub fn into_ready(self) -> Option<(u32, VirtioInputReadyResponder)> {
4921        if let VirtioInputRequest::Ready { negotiated_features, responder } = self {
4922            Some((negotiated_features, responder))
4923        } else {
4924            None
4925        }
4926    }
4927
4928    #[allow(irrefutable_let_patterns)]
4929    pub fn into_start(self) -> Option<(StartInfo, InputType, VirtioInputStartResponder)> {
4930        if let VirtioInputRequest::Start { start_info, input_type, responder } = self {
4931            Some((start_info, input_type, responder))
4932        } else {
4933            None
4934        }
4935    }
4936
4937    /// Name of the method defined in FIDL
4938    pub fn method_name(&self) -> &'static str {
4939        match *self {
4940            VirtioInputRequest::ConfigureQueue { .. } => "configure_queue",
4941            VirtioInputRequest::NotifyQueue { .. } => "notify_queue",
4942            VirtioInputRequest::Ready { .. } => "ready",
4943            VirtioInputRequest::Start { .. } => "start",
4944        }
4945    }
4946}
4947
4948#[derive(Debug, Clone)]
4949pub struct VirtioInputControlHandle {
4950    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4951}
4952
4953impl fidl::endpoints::ControlHandle for VirtioInputControlHandle {
4954    fn shutdown(&self) {
4955        self.inner.shutdown()
4956    }
4957    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4958        self.inner.shutdown_with_epitaph(status)
4959    }
4960
4961    fn is_closed(&self) -> bool {
4962        self.inner.channel().is_closed()
4963    }
4964    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4965        self.inner.channel().on_closed()
4966    }
4967
4968    #[cfg(target_os = "fuchsia")]
4969    fn signal_peer(
4970        &self,
4971        clear_mask: zx::Signals,
4972        set_mask: zx::Signals,
4973    ) -> Result<(), zx_status::Status> {
4974        use fidl::Peered;
4975        self.inner.channel().signal_peer(clear_mask, set_mask)
4976    }
4977}
4978
4979impl VirtioInputControlHandle {}
4980
4981#[must_use = "FIDL methods require a response to be sent"]
4982#[derive(Debug)]
4983pub struct VirtioInputConfigureQueueResponder {
4984    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
4985    tx_id: u32,
4986}
4987
4988/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
4989/// if the responder is dropped without sending a response, so that the client
4990/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4991impl std::ops::Drop for VirtioInputConfigureQueueResponder {
4992    fn drop(&mut self) {
4993        self.control_handle.shutdown();
4994        // Safety: drops once, never accessed again
4995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4996    }
4997}
4998
4999impl fidl::endpoints::Responder for VirtioInputConfigureQueueResponder {
5000    type ControlHandle = VirtioInputControlHandle;
5001
5002    fn control_handle(&self) -> &VirtioInputControlHandle {
5003        &self.control_handle
5004    }
5005
5006    fn drop_without_shutdown(mut self) {
5007        // Safety: drops once, never accessed again due to mem::forget
5008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5009        // Prevent Drop from running (which would shut down the channel)
5010        std::mem::forget(self);
5011    }
5012}
5013
5014impl VirtioInputConfigureQueueResponder {
5015    /// Sends a response to the FIDL transaction.
5016    ///
5017    /// Sets the channel to shutdown if an error occurs.
5018    pub fn send(self) -> Result<(), fidl::Error> {
5019        let _result = self.send_raw();
5020        if _result.is_err() {
5021            self.control_handle.shutdown();
5022        }
5023        self.drop_without_shutdown();
5024        _result
5025    }
5026
5027    /// Similar to "send" but does not shutdown the channel if an error occurs.
5028    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5029        let _result = self.send_raw();
5030        self.drop_without_shutdown();
5031        _result
5032    }
5033
5034    fn send_raw(&self) -> Result<(), fidl::Error> {
5035        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5036            (),
5037            self.tx_id,
5038            0x72b44fb963480b11,
5039            fidl::encoding::DynamicFlags::empty(),
5040        )
5041    }
5042}
5043
5044#[must_use = "FIDL methods require a response to be sent"]
5045#[derive(Debug)]
5046pub struct VirtioInputReadyResponder {
5047    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
5048    tx_id: u32,
5049}
5050
5051/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
5052/// if the responder is dropped without sending a response, so that the client
5053/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5054impl std::ops::Drop for VirtioInputReadyResponder {
5055    fn drop(&mut self) {
5056        self.control_handle.shutdown();
5057        // Safety: drops once, never accessed again
5058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5059    }
5060}
5061
5062impl fidl::endpoints::Responder for VirtioInputReadyResponder {
5063    type ControlHandle = VirtioInputControlHandle;
5064
5065    fn control_handle(&self) -> &VirtioInputControlHandle {
5066        &self.control_handle
5067    }
5068
5069    fn drop_without_shutdown(mut self) {
5070        // Safety: drops once, never accessed again due to mem::forget
5071        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5072        // Prevent Drop from running (which would shut down the channel)
5073        std::mem::forget(self);
5074    }
5075}
5076
5077impl VirtioInputReadyResponder {
5078    /// Sends a response to the FIDL transaction.
5079    ///
5080    /// Sets the channel to shutdown if an error occurs.
5081    pub fn send(self) -> Result<(), fidl::Error> {
5082        let _result = self.send_raw();
5083        if _result.is_err() {
5084            self.control_handle.shutdown();
5085        }
5086        self.drop_without_shutdown();
5087        _result
5088    }
5089
5090    /// Similar to "send" but does not shutdown the channel if an error occurs.
5091    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5092        let _result = self.send_raw();
5093        self.drop_without_shutdown();
5094        _result
5095    }
5096
5097    fn send_raw(&self) -> Result<(), fidl::Error> {
5098        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5099            (),
5100            self.tx_id,
5101            0x45707654f5d23c3f,
5102            fidl::encoding::DynamicFlags::empty(),
5103        )
5104    }
5105}
5106
5107#[must_use = "FIDL methods require a response to be sent"]
5108#[derive(Debug)]
5109pub struct VirtioInputStartResponder {
5110    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
5111    tx_id: u32,
5112}
5113
5114/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
5115/// if the responder is dropped without sending a response, so that the client
5116/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5117impl std::ops::Drop for VirtioInputStartResponder {
5118    fn drop(&mut self) {
5119        self.control_handle.shutdown();
5120        // Safety: drops once, never accessed again
5121        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5122    }
5123}
5124
5125impl fidl::endpoints::Responder for VirtioInputStartResponder {
5126    type ControlHandle = VirtioInputControlHandle;
5127
5128    fn control_handle(&self) -> &VirtioInputControlHandle {
5129        &self.control_handle
5130    }
5131
5132    fn drop_without_shutdown(mut self) {
5133        // Safety: drops once, never accessed again due to mem::forget
5134        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5135        // Prevent Drop from running (which would shut down the channel)
5136        std::mem::forget(self);
5137    }
5138}
5139
5140impl VirtioInputStartResponder {
5141    /// Sends a response to the FIDL transaction.
5142    ///
5143    /// Sets the channel to shutdown if an error occurs.
5144    pub fn send(self) -> Result<(), fidl::Error> {
5145        let _result = self.send_raw();
5146        if _result.is_err() {
5147            self.control_handle.shutdown();
5148        }
5149        self.drop_without_shutdown();
5150        _result
5151    }
5152
5153    /// Similar to "send" but does not shutdown the channel if an error occurs.
5154    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5155        let _result = self.send_raw();
5156        self.drop_without_shutdown();
5157        _result
5158    }
5159
5160    fn send_raw(&self) -> Result<(), fidl::Error> {
5161        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5162            (),
5163            self.tx_id,
5164            0x612743931f7f9249,
5165            fidl::encoding::DynamicFlags::empty(),
5166        )
5167    }
5168}
5169
5170#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5171pub struct VirtioMagmaMarker;
5172
5173impl fidl::endpoints::ProtocolMarker for VirtioMagmaMarker {
5174    type Proxy = VirtioMagmaProxy;
5175    type RequestStream = VirtioMagmaRequestStream;
5176    #[cfg(target_os = "fuchsia")]
5177    type SynchronousProxy = VirtioMagmaSynchronousProxy;
5178
5179    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioMagma";
5180}
5181impl fidl::endpoints::DiscoverableProtocolMarker for VirtioMagmaMarker {}
5182
5183pub trait VirtioMagmaProxyInterface: Send + Sync {
5184    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5185    fn r#configure_queue(
5186        &self,
5187        queue: u16,
5188        size: u16,
5189        desc: u64,
5190        avail: u64,
5191        used: u64,
5192    ) -> Self::ConfigureQueueResponseFut;
5193    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
5194    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5195    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
5196    type StartResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
5197    fn r#start(
5198        &self,
5199        start_info: StartInfo,
5200        vmar: fidl::Vmar,
5201        wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5202    ) -> Self::StartResponseFut;
5203}
5204#[derive(Debug)]
5205#[cfg(target_os = "fuchsia")]
5206pub struct VirtioMagmaSynchronousProxy {
5207    client: fidl::client::sync::Client,
5208}
5209
5210#[cfg(target_os = "fuchsia")]
5211impl fidl::endpoints::SynchronousProxy for VirtioMagmaSynchronousProxy {
5212    type Proxy = VirtioMagmaProxy;
5213    type Protocol = VirtioMagmaMarker;
5214
5215    fn from_channel(inner: fidl::Channel) -> Self {
5216        Self::new(inner)
5217    }
5218
5219    fn into_channel(self) -> fidl::Channel {
5220        self.client.into_channel()
5221    }
5222
5223    fn as_channel(&self) -> &fidl::Channel {
5224        self.client.as_channel()
5225    }
5226}
5227
5228#[cfg(target_os = "fuchsia")]
5229impl VirtioMagmaSynchronousProxy {
5230    pub fn new(channel: fidl::Channel) -> Self {
5231        let protocol_name = <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5232        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5233    }
5234
5235    pub fn into_channel(self) -> fidl::Channel {
5236        self.client.into_channel()
5237    }
5238
5239    /// Waits until an event arrives and returns it. It is safe for other
5240    /// threads to make concurrent requests while waiting for an event.
5241    pub fn wait_for_event(
5242        &self,
5243        deadline: zx::MonotonicInstant,
5244    ) -> Result<VirtioMagmaEvent, fidl::Error> {
5245        VirtioMagmaEvent::decode(self.client.wait_for_event(deadline)?)
5246    }
5247
5248    /// Configure a `queue` for the device. This specifies the `size` and the
5249    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5250    pub fn r#configure_queue(
5251        &self,
5252        mut queue: u16,
5253        mut size: u16,
5254        mut desc: u64,
5255        mut avail: u64,
5256        mut used: u64,
5257        ___deadline: zx::MonotonicInstant,
5258    ) -> Result<(), fidl::Error> {
5259        let _response = self
5260            .client
5261            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
5262                (queue, size, desc, avail, used),
5263                0x72b44fb963480b11,
5264                fidl::encoding::DynamicFlags::empty(),
5265                ___deadline,
5266            )?;
5267        Ok(_response)
5268    }
5269
5270    /// Notify a `queue` for the device. Primarily used for black-box testing.
5271    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5272        self.client.send::<VirtioDeviceNotifyQueueRequest>(
5273            (queue,),
5274            0x6e3a61d652499244,
5275            fidl::encoding::DynamicFlags::empty(),
5276        )
5277    }
5278
5279    /// Ready a device. This provides the set of `negotiated_features` that the
5280    /// driver and device have agreed upon.
5281    pub fn r#ready(
5282        &self,
5283        mut negotiated_features: u32,
5284        ___deadline: zx::MonotonicInstant,
5285    ) -> Result<(), fidl::Error> {
5286        let _response =
5287            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
5288                (negotiated_features,),
5289                0x45707654f5d23c3f,
5290                fidl::encoding::DynamicFlags::empty(),
5291                ___deadline,
5292            )?;
5293        Ok(_response)
5294    }
5295
5296    /// Start the magma device.
5297    pub fn r#start(
5298        &self,
5299        mut start_info: StartInfo,
5300        mut vmar: fidl::Vmar,
5301        mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5302        ___deadline: zx::MonotonicInstant,
5303    ) -> Result<i32, fidl::Error> {
5304        let _response =
5305            self.client.send_query::<VirtioMagmaStartRequest, VirtioMagmaStartResponse>(
5306                (&mut start_info, vmar, wayland_importer),
5307                0x6b94e28f73d201e2,
5308                fidl::encoding::DynamicFlags::empty(),
5309                ___deadline,
5310            )?;
5311        Ok(_response.status)
5312    }
5313}
5314
5315#[cfg(target_os = "fuchsia")]
5316impl From<VirtioMagmaSynchronousProxy> for zx::Handle {
5317    fn from(value: VirtioMagmaSynchronousProxy) -> Self {
5318        value.into_channel().into()
5319    }
5320}
5321
5322#[cfg(target_os = "fuchsia")]
5323impl From<fidl::Channel> for VirtioMagmaSynchronousProxy {
5324    fn from(value: fidl::Channel) -> Self {
5325        Self::new(value)
5326    }
5327}
5328
5329#[derive(Debug, Clone)]
5330pub struct VirtioMagmaProxy {
5331    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5332}
5333
5334impl fidl::endpoints::Proxy for VirtioMagmaProxy {
5335    type Protocol = VirtioMagmaMarker;
5336
5337    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5338        Self::new(inner)
5339    }
5340
5341    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5342        self.client.into_channel().map_err(|client| Self { client })
5343    }
5344
5345    fn as_channel(&self) -> &::fidl::AsyncChannel {
5346        self.client.as_channel()
5347    }
5348}
5349
5350impl VirtioMagmaProxy {
5351    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioMagma.
5352    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5353        let protocol_name = <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5354        Self { client: fidl::client::Client::new(channel, protocol_name) }
5355    }
5356
5357    /// Get a Stream of events from the remote end of the protocol.
5358    ///
5359    /// # Panics
5360    ///
5361    /// Panics if the event stream was already taken.
5362    pub fn take_event_stream(&self) -> VirtioMagmaEventStream {
5363        VirtioMagmaEventStream { event_receiver: self.client.take_event_receiver() }
5364    }
5365
5366    /// Configure a `queue` for the device. This specifies the `size` and the
5367    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5368    pub fn r#configure_queue(
5369        &self,
5370        mut queue: u16,
5371        mut size: u16,
5372        mut desc: u64,
5373        mut avail: u64,
5374        mut used: u64,
5375    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5376        VirtioMagmaProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
5377    }
5378
5379    /// Notify a `queue` for the device. Primarily used for black-box testing.
5380    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5381        VirtioMagmaProxyInterface::r#notify_queue(self, queue)
5382    }
5383
5384    /// Ready a device. This provides the set of `negotiated_features` that the
5385    /// driver and device have agreed upon.
5386    pub fn r#ready(
5387        &self,
5388        mut negotiated_features: u32,
5389    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5390        VirtioMagmaProxyInterface::r#ready(self, negotiated_features)
5391    }
5392
5393    /// Start the magma device.
5394    pub fn r#start(
5395        &self,
5396        mut start_info: StartInfo,
5397        mut vmar: fidl::Vmar,
5398        mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5399    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5400        VirtioMagmaProxyInterface::r#start(self, start_info, vmar, wayland_importer)
5401    }
5402}
5403
5404impl VirtioMagmaProxyInterface for VirtioMagmaProxy {
5405    type ConfigureQueueResponseFut =
5406        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5407    fn r#configure_queue(
5408        &self,
5409        mut queue: u16,
5410        mut size: u16,
5411        mut desc: u64,
5412        mut avail: u64,
5413        mut used: u64,
5414    ) -> Self::ConfigureQueueResponseFut {
5415        fn _decode(
5416            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5417        ) -> Result<(), fidl::Error> {
5418            let _response = fidl::client::decode_transaction_body::<
5419                fidl::encoding::EmptyPayload,
5420                fidl::encoding::DefaultFuchsiaResourceDialect,
5421                0x72b44fb963480b11,
5422            >(_buf?)?;
5423            Ok(_response)
5424        }
5425        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
5426            (queue, size, desc, avail, used),
5427            0x72b44fb963480b11,
5428            fidl::encoding::DynamicFlags::empty(),
5429            _decode,
5430        )
5431    }
5432
5433    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5434        self.client.send::<VirtioDeviceNotifyQueueRequest>(
5435            (queue,),
5436            0x6e3a61d652499244,
5437            fidl::encoding::DynamicFlags::empty(),
5438        )
5439    }
5440
5441    type ReadyResponseFut =
5442        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5443    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
5444        fn _decode(
5445            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5446        ) -> Result<(), fidl::Error> {
5447            let _response = fidl::client::decode_transaction_body::<
5448                fidl::encoding::EmptyPayload,
5449                fidl::encoding::DefaultFuchsiaResourceDialect,
5450                0x45707654f5d23c3f,
5451            >(_buf?)?;
5452            Ok(_response)
5453        }
5454        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
5455            (negotiated_features,),
5456            0x45707654f5d23c3f,
5457            fidl::encoding::DynamicFlags::empty(),
5458            _decode,
5459        )
5460    }
5461
5462    type StartResponseFut =
5463        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5464    fn r#start(
5465        &self,
5466        mut start_info: StartInfo,
5467        mut vmar: fidl::Vmar,
5468        mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5469    ) -> Self::StartResponseFut {
5470        fn _decode(
5471            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5472        ) -> Result<i32, fidl::Error> {
5473            let _response = fidl::client::decode_transaction_body::<
5474                VirtioMagmaStartResponse,
5475                fidl::encoding::DefaultFuchsiaResourceDialect,
5476                0x6b94e28f73d201e2,
5477            >(_buf?)?;
5478            Ok(_response.status)
5479        }
5480        self.client.send_query_and_decode::<VirtioMagmaStartRequest, i32>(
5481            (&mut start_info, vmar, wayland_importer),
5482            0x6b94e28f73d201e2,
5483            fidl::encoding::DynamicFlags::empty(),
5484            _decode,
5485        )
5486    }
5487}
5488
5489pub struct VirtioMagmaEventStream {
5490    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5491}
5492
5493impl std::marker::Unpin for VirtioMagmaEventStream {}
5494
5495impl futures::stream::FusedStream for VirtioMagmaEventStream {
5496    fn is_terminated(&self) -> bool {
5497        self.event_receiver.is_terminated()
5498    }
5499}
5500
5501impl futures::Stream for VirtioMagmaEventStream {
5502    type Item = Result<VirtioMagmaEvent, fidl::Error>;
5503
5504    fn poll_next(
5505        mut self: std::pin::Pin<&mut Self>,
5506        cx: &mut std::task::Context<'_>,
5507    ) -> std::task::Poll<Option<Self::Item>> {
5508        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5509            &mut self.event_receiver,
5510            cx
5511        )?) {
5512            Some(buf) => std::task::Poll::Ready(Some(VirtioMagmaEvent::decode(buf))),
5513            None => std::task::Poll::Ready(None),
5514        }
5515    }
5516}
5517
5518#[derive(Debug)]
5519pub enum VirtioMagmaEvent {}
5520
5521impl VirtioMagmaEvent {
5522    /// Decodes a message buffer as a [`VirtioMagmaEvent`].
5523    fn decode(
5524        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5525    ) -> Result<VirtioMagmaEvent, fidl::Error> {
5526        let (bytes, _handles) = buf.split_mut();
5527        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5528        debug_assert_eq!(tx_header.tx_id, 0);
5529        match tx_header.ordinal {
5530            _ => Err(fidl::Error::UnknownOrdinal {
5531                ordinal: tx_header.ordinal,
5532                protocol_name: <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5533            }),
5534        }
5535    }
5536}
5537
5538/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioMagma.
5539pub struct VirtioMagmaRequestStream {
5540    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5541    is_terminated: bool,
5542}
5543
5544impl std::marker::Unpin for VirtioMagmaRequestStream {}
5545
5546impl futures::stream::FusedStream for VirtioMagmaRequestStream {
5547    fn is_terminated(&self) -> bool {
5548        self.is_terminated
5549    }
5550}
5551
5552impl fidl::endpoints::RequestStream for VirtioMagmaRequestStream {
5553    type Protocol = VirtioMagmaMarker;
5554    type ControlHandle = VirtioMagmaControlHandle;
5555
5556    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5557        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5558    }
5559
5560    fn control_handle(&self) -> Self::ControlHandle {
5561        VirtioMagmaControlHandle { inner: self.inner.clone() }
5562    }
5563
5564    fn into_inner(
5565        self,
5566    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5567    {
5568        (self.inner, self.is_terminated)
5569    }
5570
5571    fn from_inner(
5572        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5573        is_terminated: bool,
5574    ) -> Self {
5575        Self { inner, is_terminated }
5576    }
5577}
5578
5579impl futures::Stream for VirtioMagmaRequestStream {
5580    type Item = Result<VirtioMagmaRequest, fidl::Error>;
5581
5582    fn poll_next(
5583        mut self: std::pin::Pin<&mut Self>,
5584        cx: &mut std::task::Context<'_>,
5585    ) -> std::task::Poll<Option<Self::Item>> {
5586        let this = &mut *self;
5587        if this.inner.check_shutdown(cx) {
5588            this.is_terminated = true;
5589            return std::task::Poll::Ready(None);
5590        }
5591        if this.is_terminated {
5592            panic!("polled VirtioMagmaRequestStream after completion");
5593        }
5594        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5595            |bytes, handles| {
5596                match this.inner.channel().read_etc(cx, bytes, handles) {
5597                    std::task::Poll::Ready(Ok(())) => {}
5598                    std::task::Poll::Pending => return std::task::Poll::Pending,
5599                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5600                        this.is_terminated = true;
5601                        return std::task::Poll::Ready(None);
5602                    }
5603                    std::task::Poll::Ready(Err(e)) => {
5604                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5605                            e.into(),
5606                        ))))
5607                    }
5608                }
5609
5610                // A message has been received from the channel
5611                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5612
5613                std::task::Poll::Ready(Some(match header.ordinal {
5614                    0x72b44fb963480b11 => {
5615                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5616                        let mut req = fidl::new_empty!(
5617                            VirtioDeviceConfigureQueueRequest,
5618                            fidl::encoding::DefaultFuchsiaResourceDialect
5619                        );
5620                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
5621                        let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
5622                        Ok(VirtioMagmaRequest::ConfigureQueue {
5623                            queue: req.queue,
5624                            size: req.size,
5625                            desc: req.desc,
5626                            avail: req.avail,
5627                            used: req.used,
5628
5629                            responder: VirtioMagmaConfigureQueueResponder {
5630                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5631                                tx_id: header.tx_id,
5632                            },
5633                        })
5634                    }
5635                    0x6e3a61d652499244 => {
5636                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5637                        let mut req = fidl::new_empty!(
5638                            VirtioDeviceNotifyQueueRequest,
5639                            fidl::encoding::DefaultFuchsiaResourceDialect
5640                        );
5641                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
5642                        let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
5643                        Ok(VirtioMagmaRequest::NotifyQueue { queue: req.queue, control_handle })
5644                    }
5645                    0x45707654f5d23c3f => {
5646                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5647                        let mut req = fidl::new_empty!(
5648                            VirtioDeviceReadyRequest,
5649                            fidl::encoding::DefaultFuchsiaResourceDialect
5650                        );
5651                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
5652                        let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
5653                        Ok(VirtioMagmaRequest::Ready {
5654                            negotiated_features: req.negotiated_features,
5655
5656                            responder: VirtioMagmaReadyResponder {
5657                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5658                                tx_id: header.tx_id,
5659                            },
5660                        })
5661                    }
5662                    0x6b94e28f73d201e2 => {
5663                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5664                        let mut req = fidl::new_empty!(
5665                            VirtioMagmaStartRequest,
5666                            fidl::encoding::DefaultFuchsiaResourceDialect
5667                        );
5668                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMagmaStartRequest>(&header, _body_bytes, handles, &mut req)?;
5669                        let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
5670                        Ok(VirtioMagmaRequest::Start {
5671                            start_info: req.start_info,
5672                            vmar: req.vmar,
5673                            wayland_importer: req.wayland_importer,
5674
5675                            responder: VirtioMagmaStartResponder {
5676                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5677                                tx_id: header.tx_id,
5678                            },
5679                        })
5680                    }
5681                    _ => Err(fidl::Error::UnknownOrdinal {
5682                        ordinal: header.ordinal,
5683                        protocol_name:
5684                            <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5685                    }),
5686                }))
5687            },
5688        )
5689    }
5690}
5691
5692#[derive(Debug)]
5693pub enum VirtioMagmaRequest {
5694    /// Configure a `queue` for the device. This specifies the `size` and the
5695    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5696    ConfigureQueue {
5697        queue: u16,
5698        size: u16,
5699        desc: u64,
5700        avail: u64,
5701        used: u64,
5702        responder: VirtioMagmaConfigureQueueResponder,
5703    },
5704    /// Notify a `queue` for the device. Primarily used for black-box testing.
5705    NotifyQueue { queue: u16, control_handle: VirtioMagmaControlHandle },
5706    /// Ready a device. This provides the set of `negotiated_features` that the
5707    /// driver and device have agreed upon.
5708    Ready { negotiated_features: u32, responder: VirtioMagmaReadyResponder },
5709    /// Start the magma device.
5710    Start {
5711        start_info: StartInfo,
5712        vmar: fidl::Vmar,
5713        wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5714        responder: VirtioMagmaStartResponder,
5715    },
5716}
5717
5718impl VirtioMagmaRequest {
5719    #[allow(irrefutable_let_patterns)]
5720    pub fn into_configure_queue(
5721        self,
5722    ) -> Option<(u16, u16, u64, u64, u64, VirtioMagmaConfigureQueueResponder)> {
5723        if let VirtioMagmaRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
5724            self
5725        {
5726            Some((queue, size, desc, avail, used, responder))
5727        } else {
5728            None
5729        }
5730    }
5731
5732    #[allow(irrefutable_let_patterns)]
5733    pub fn into_notify_queue(self) -> Option<(u16, VirtioMagmaControlHandle)> {
5734        if let VirtioMagmaRequest::NotifyQueue { queue, control_handle } = self {
5735            Some((queue, control_handle))
5736        } else {
5737            None
5738        }
5739    }
5740
5741    #[allow(irrefutable_let_patterns)]
5742    pub fn into_ready(self) -> Option<(u32, VirtioMagmaReadyResponder)> {
5743        if let VirtioMagmaRequest::Ready { negotiated_features, responder } = self {
5744            Some((negotiated_features, responder))
5745        } else {
5746            None
5747        }
5748    }
5749
5750    #[allow(irrefutable_let_patterns)]
5751    pub fn into_start(
5752        self,
5753    ) -> Option<(
5754        StartInfo,
5755        fidl::Vmar,
5756        Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
5757        VirtioMagmaStartResponder,
5758    )> {
5759        if let VirtioMagmaRequest::Start { start_info, vmar, wayland_importer, responder } = self {
5760            Some((start_info, vmar, wayland_importer, responder))
5761        } else {
5762            None
5763        }
5764    }
5765
5766    /// Name of the method defined in FIDL
5767    pub fn method_name(&self) -> &'static str {
5768        match *self {
5769            VirtioMagmaRequest::ConfigureQueue { .. } => "configure_queue",
5770            VirtioMagmaRequest::NotifyQueue { .. } => "notify_queue",
5771            VirtioMagmaRequest::Ready { .. } => "ready",
5772            VirtioMagmaRequest::Start { .. } => "start",
5773        }
5774    }
5775}
5776
5777#[derive(Debug, Clone)]
5778pub struct VirtioMagmaControlHandle {
5779    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5780}
5781
5782impl fidl::endpoints::ControlHandle for VirtioMagmaControlHandle {
5783    fn shutdown(&self) {
5784        self.inner.shutdown()
5785    }
5786    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5787        self.inner.shutdown_with_epitaph(status)
5788    }
5789
5790    fn is_closed(&self) -> bool {
5791        self.inner.channel().is_closed()
5792    }
5793    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5794        self.inner.channel().on_closed()
5795    }
5796
5797    #[cfg(target_os = "fuchsia")]
5798    fn signal_peer(
5799        &self,
5800        clear_mask: zx::Signals,
5801        set_mask: zx::Signals,
5802    ) -> Result<(), zx_status::Status> {
5803        use fidl::Peered;
5804        self.inner.channel().signal_peer(clear_mask, set_mask)
5805    }
5806}
5807
5808impl VirtioMagmaControlHandle {}
5809
5810#[must_use = "FIDL methods require a response to be sent"]
5811#[derive(Debug)]
5812pub struct VirtioMagmaConfigureQueueResponder {
5813    control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
5814    tx_id: u32,
5815}
5816
5817/// Set the the channel to be shutdown (see [`VirtioMagmaControlHandle::shutdown`])
5818/// if the responder is dropped without sending a response, so that the client
5819/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5820impl std::ops::Drop for VirtioMagmaConfigureQueueResponder {
5821    fn drop(&mut self) {
5822        self.control_handle.shutdown();
5823        // Safety: drops once, never accessed again
5824        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5825    }
5826}
5827
5828impl fidl::endpoints::Responder for VirtioMagmaConfigureQueueResponder {
5829    type ControlHandle = VirtioMagmaControlHandle;
5830
5831    fn control_handle(&self) -> &VirtioMagmaControlHandle {
5832        &self.control_handle
5833    }
5834
5835    fn drop_without_shutdown(mut self) {
5836        // Safety: drops once, never accessed again due to mem::forget
5837        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5838        // Prevent Drop from running (which would shut down the channel)
5839        std::mem::forget(self);
5840    }
5841}
5842
5843impl VirtioMagmaConfigureQueueResponder {
5844    /// Sends a response to the FIDL transaction.
5845    ///
5846    /// Sets the channel to shutdown if an error occurs.
5847    pub fn send(self) -> Result<(), fidl::Error> {
5848        let _result = self.send_raw();
5849        if _result.is_err() {
5850            self.control_handle.shutdown();
5851        }
5852        self.drop_without_shutdown();
5853        _result
5854    }
5855
5856    /// Similar to "send" but does not shutdown the channel if an error occurs.
5857    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5858        let _result = self.send_raw();
5859        self.drop_without_shutdown();
5860        _result
5861    }
5862
5863    fn send_raw(&self) -> Result<(), fidl::Error> {
5864        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5865            (),
5866            self.tx_id,
5867            0x72b44fb963480b11,
5868            fidl::encoding::DynamicFlags::empty(),
5869        )
5870    }
5871}
5872
5873#[must_use = "FIDL methods require a response to be sent"]
5874#[derive(Debug)]
5875pub struct VirtioMagmaReadyResponder {
5876    control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
5877    tx_id: u32,
5878}
5879
5880/// Set the the channel to be shutdown (see [`VirtioMagmaControlHandle::shutdown`])
5881/// if the responder is dropped without sending a response, so that the client
5882/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5883impl std::ops::Drop for VirtioMagmaReadyResponder {
5884    fn drop(&mut self) {
5885        self.control_handle.shutdown();
5886        // Safety: drops once, never accessed again
5887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5888    }
5889}
5890
5891impl fidl::endpoints::Responder for VirtioMagmaReadyResponder {
5892    type ControlHandle = VirtioMagmaControlHandle;
5893
5894    fn control_handle(&self) -> &VirtioMagmaControlHandle {
5895        &self.control_handle
5896    }
5897
5898    fn drop_without_shutdown(mut self) {
5899        // Safety: drops once, never accessed again due to mem::forget
5900        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5901        // Prevent Drop from running (which would shut down the channel)
5902        std::mem::forget(self);
5903    }
5904}
5905
5906impl VirtioMagmaReadyResponder {
5907    /// Sends a response to the FIDL transaction.
5908    ///
5909    /// Sets the channel to shutdown if an error occurs.
5910    pub fn send(self) -> Result<(), fidl::Error> {
5911        let _result = self.send_raw();
5912        if _result.is_err() {
5913            self.control_handle.shutdown();
5914        }
5915        self.drop_without_shutdown();
5916        _result
5917    }
5918
5919    /// Similar to "send" but does not shutdown the channel if an error occurs.
5920    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5921        let _result = self.send_raw();
5922        self.drop_without_shutdown();
5923        _result
5924    }
5925
5926    fn send_raw(&self) -> Result<(), fidl::Error> {
5927        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5928            (),
5929            self.tx_id,
5930            0x45707654f5d23c3f,
5931            fidl::encoding::DynamicFlags::empty(),
5932        )
5933    }
5934}
5935
5936#[must_use = "FIDL methods require a response to be sent"]
5937#[derive(Debug)]
5938pub struct VirtioMagmaStartResponder {
5939    control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
5940    tx_id: u32,
5941}
5942
5943/// Set the the channel to be shutdown (see [`VirtioMagmaControlHandle::shutdown`])
5944/// if the responder is dropped without sending a response, so that the client
5945/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5946impl std::ops::Drop for VirtioMagmaStartResponder {
5947    fn drop(&mut self) {
5948        self.control_handle.shutdown();
5949        // Safety: drops once, never accessed again
5950        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5951    }
5952}
5953
5954impl fidl::endpoints::Responder for VirtioMagmaStartResponder {
5955    type ControlHandle = VirtioMagmaControlHandle;
5956
5957    fn control_handle(&self) -> &VirtioMagmaControlHandle {
5958        &self.control_handle
5959    }
5960
5961    fn drop_without_shutdown(mut self) {
5962        // Safety: drops once, never accessed again due to mem::forget
5963        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5964        // Prevent Drop from running (which would shut down the channel)
5965        std::mem::forget(self);
5966    }
5967}
5968
5969impl VirtioMagmaStartResponder {
5970    /// Sends a response to the FIDL transaction.
5971    ///
5972    /// Sets the channel to shutdown if an error occurs.
5973    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
5974        let _result = self.send_raw(status);
5975        if _result.is_err() {
5976            self.control_handle.shutdown();
5977        }
5978        self.drop_without_shutdown();
5979        _result
5980    }
5981
5982    /// Similar to "send" but does not shutdown the channel if an error occurs.
5983    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
5984        let _result = self.send_raw(status);
5985        self.drop_without_shutdown();
5986        _result
5987    }
5988
5989    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
5990        self.control_handle.inner.send::<VirtioMagmaStartResponse>(
5991            (status,),
5992            self.tx_id,
5993            0x6b94e28f73d201e2,
5994            fidl::encoding::DynamicFlags::empty(),
5995        )
5996    }
5997}
5998
5999#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6000pub struct VirtioMemMarker;
6001
6002impl fidl::endpoints::ProtocolMarker for VirtioMemMarker {
6003    type Proxy = VirtioMemProxy;
6004    type RequestStream = VirtioMemRequestStream;
6005    #[cfg(target_os = "fuchsia")]
6006    type SynchronousProxy = VirtioMemSynchronousProxy;
6007
6008    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioMem";
6009}
6010impl fidl::endpoints::DiscoverableProtocolMarker for VirtioMemMarker {}
6011
6012pub trait VirtioMemProxyInterface: Send + Sync {
6013    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6014    fn r#configure_queue(
6015        &self,
6016        queue: u16,
6017        size: u16,
6018        desc: u64,
6019        avail: u64,
6020        used: u64,
6021    ) -> Self::ConfigureQueueResponseFut;
6022    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
6023    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6024    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
6025    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6026    fn r#start(
6027        &self,
6028        start_info: StartInfo,
6029        region_addr: u64,
6030        plugged_block_size: u64,
6031        region_size: u64,
6032    ) -> Self::StartResponseFut;
6033}
6034#[derive(Debug)]
6035#[cfg(target_os = "fuchsia")]
6036pub struct VirtioMemSynchronousProxy {
6037    client: fidl::client::sync::Client,
6038}
6039
6040#[cfg(target_os = "fuchsia")]
6041impl fidl::endpoints::SynchronousProxy for VirtioMemSynchronousProxy {
6042    type Proxy = VirtioMemProxy;
6043    type Protocol = VirtioMemMarker;
6044
6045    fn from_channel(inner: fidl::Channel) -> Self {
6046        Self::new(inner)
6047    }
6048
6049    fn into_channel(self) -> fidl::Channel {
6050        self.client.into_channel()
6051    }
6052
6053    fn as_channel(&self) -> &fidl::Channel {
6054        self.client.as_channel()
6055    }
6056}
6057
6058#[cfg(target_os = "fuchsia")]
6059impl VirtioMemSynchronousProxy {
6060    pub fn new(channel: fidl::Channel) -> Self {
6061        let protocol_name = <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6062        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6063    }
6064
6065    pub fn into_channel(self) -> fidl::Channel {
6066        self.client.into_channel()
6067    }
6068
6069    /// Waits until an event arrives and returns it. It is safe for other
6070    /// threads to make concurrent requests while waiting for an event.
6071    pub fn wait_for_event(
6072        &self,
6073        deadline: zx::MonotonicInstant,
6074    ) -> Result<VirtioMemEvent, fidl::Error> {
6075        VirtioMemEvent::decode(self.client.wait_for_event(deadline)?)
6076    }
6077
6078    /// Configure a `queue` for the device. This specifies the `size` and the
6079    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6080    pub fn r#configure_queue(
6081        &self,
6082        mut queue: u16,
6083        mut size: u16,
6084        mut desc: u64,
6085        mut avail: u64,
6086        mut used: u64,
6087        ___deadline: zx::MonotonicInstant,
6088    ) -> Result<(), fidl::Error> {
6089        let _response = self
6090            .client
6091            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
6092                (queue, size, desc, avail, used),
6093                0x72b44fb963480b11,
6094                fidl::encoding::DynamicFlags::empty(),
6095                ___deadline,
6096            )?;
6097        Ok(_response)
6098    }
6099
6100    /// Notify a `queue` for the device. Primarily used for black-box testing.
6101    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6102        self.client.send::<VirtioDeviceNotifyQueueRequest>(
6103            (queue,),
6104            0x6e3a61d652499244,
6105            fidl::encoding::DynamicFlags::empty(),
6106        )
6107    }
6108
6109    /// Ready a device. This provides the set of `negotiated_features` that the
6110    /// driver and device have agreed upon.
6111    pub fn r#ready(
6112        &self,
6113        mut negotiated_features: u32,
6114        ___deadline: zx::MonotonicInstant,
6115    ) -> Result<(), fidl::Error> {
6116        let _response =
6117            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
6118                (negotiated_features,),
6119                0x45707654f5d23c3f,
6120                fidl::encoding::DynamicFlags::empty(),
6121                ___deadline,
6122            )?;
6123        Ok(_response)
6124    }
6125
6126    /// Start the mem device.
6127    pub fn r#start(
6128        &self,
6129        mut start_info: StartInfo,
6130        mut region_addr: u64,
6131        mut plugged_block_size: u64,
6132        mut region_size: u64,
6133        ___deadline: zx::MonotonicInstant,
6134    ) -> Result<(), fidl::Error> {
6135        let _response =
6136            self.client.send_query::<VirtioMemStartRequest, fidl::encoding::EmptyPayload>(
6137                (&mut start_info, region_addr, plugged_block_size, region_size),
6138                0x66dd64f17fb5223c,
6139                fidl::encoding::DynamicFlags::empty(),
6140                ___deadline,
6141            )?;
6142        Ok(_response)
6143    }
6144}
6145
6146#[cfg(target_os = "fuchsia")]
6147impl From<VirtioMemSynchronousProxy> for zx::Handle {
6148    fn from(value: VirtioMemSynchronousProxy) -> Self {
6149        value.into_channel().into()
6150    }
6151}
6152
6153#[cfg(target_os = "fuchsia")]
6154impl From<fidl::Channel> for VirtioMemSynchronousProxy {
6155    fn from(value: fidl::Channel) -> Self {
6156        Self::new(value)
6157    }
6158}
6159
6160#[derive(Debug, Clone)]
6161pub struct VirtioMemProxy {
6162    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6163}
6164
6165impl fidl::endpoints::Proxy for VirtioMemProxy {
6166    type Protocol = VirtioMemMarker;
6167
6168    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6169        Self::new(inner)
6170    }
6171
6172    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6173        self.client.into_channel().map_err(|client| Self { client })
6174    }
6175
6176    fn as_channel(&self) -> &::fidl::AsyncChannel {
6177        self.client.as_channel()
6178    }
6179}
6180
6181impl VirtioMemProxy {
6182    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioMem.
6183    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6184        let protocol_name = <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6185        Self { client: fidl::client::Client::new(channel, protocol_name) }
6186    }
6187
6188    /// Get a Stream of events from the remote end of the protocol.
6189    ///
6190    /// # Panics
6191    ///
6192    /// Panics if the event stream was already taken.
6193    pub fn take_event_stream(&self) -> VirtioMemEventStream {
6194        VirtioMemEventStream { event_receiver: self.client.take_event_receiver() }
6195    }
6196
6197    /// Configure a `queue` for the device. This specifies the `size` and the
6198    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6199    pub fn r#configure_queue(
6200        &self,
6201        mut queue: u16,
6202        mut size: u16,
6203        mut desc: u64,
6204        mut avail: u64,
6205        mut used: u64,
6206    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6207        VirtioMemProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
6208    }
6209
6210    /// Notify a `queue` for the device. Primarily used for black-box testing.
6211    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6212        VirtioMemProxyInterface::r#notify_queue(self, queue)
6213    }
6214
6215    /// Ready a device. This provides the set of `negotiated_features` that the
6216    /// driver and device have agreed upon.
6217    pub fn r#ready(
6218        &self,
6219        mut negotiated_features: u32,
6220    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6221        VirtioMemProxyInterface::r#ready(self, negotiated_features)
6222    }
6223
6224    /// Start the mem device.
6225    pub fn r#start(
6226        &self,
6227        mut start_info: StartInfo,
6228        mut region_addr: u64,
6229        mut plugged_block_size: u64,
6230        mut region_size: u64,
6231    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6232        VirtioMemProxyInterface::r#start(
6233            self,
6234            start_info,
6235            region_addr,
6236            plugged_block_size,
6237            region_size,
6238        )
6239    }
6240}
6241
6242impl VirtioMemProxyInterface for VirtioMemProxy {
6243    type ConfigureQueueResponseFut =
6244        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6245    fn r#configure_queue(
6246        &self,
6247        mut queue: u16,
6248        mut size: u16,
6249        mut desc: u64,
6250        mut avail: u64,
6251        mut used: u64,
6252    ) -> Self::ConfigureQueueResponseFut {
6253        fn _decode(
6254            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6255        ) -> Result<(), fidl::Error> {
6256            let _response = fidl::client::decode_transaction_body::<
6257                fidl::encoding::EmptyPayload,
6258                fidl::encoding::DefaultFuchsiaResourceDialect,
6259                0x72b44fb963480b11,
6260            >(_buf?)?;
6261            Ok(_response)
6262        }
6263        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
6264            (queue, size, desc, avail, used),
6265            0x72b44fb963480b11,
6266            fidl::encoding::DynamicFlags::empty(),
6267            _decode,
6268        )
6269    }
6270
6271    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6272        self.client.send::<VirtioDeviceNotifyQueueRequest>(
6273            (queue,),
6274            0x6e3a61d652499244,
6275            fidl::encoding::DynamicFlags::empty(),
6276        )
6277    }
6278
6279    type ReadyResponseFut =
6280        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6281    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
6282        fn _decode(
6283            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6284        ) -> Result<(), fidl::Error> {
6285            let _response = fidl::client::decode_transaction_body::<
6286                fidl::encoding::EmptyPayload,
6287                fidl::encoding::DefaultFuchsiaResourceDialect,
6288                0x45707654f5d23c3f,
6289            >(_buf?)?;
6290            Ok(_response)
6291        }
6292        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
6293            (negotiated_features,),
6294            0x45707654f5d23c3f,
6295            fidl::encoding::DynamicFlags::empty(),
6296            _decode,
6297        )
6298    }
6299
6300    type StartResponseFut =
6301        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6302    fn r#start(
6303        &self,
6304        mut start_info: StartInfo,
6305        mut region_addr: u64,
6306        mut plugged_block_size: u64,
6307        mut region_size: u64,
6308    ) -> Self::StartResponseFut {
6309        fn _decode(
6310            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6311        ) -> Result<(), fidl::Error> {
6312            let _response = fidl::client::decode_transaction_body::<
6313                fidl::encoding::EmptyPayload,
6314                fidl::encoding::DefaultFuchsiaResourceDialect,
6315                0x66dd64f17fb5223c,
6316            >(_buf?)?;
6317            Ok(_response)
6318        }
6319        self.client.send_query_and_decode::<VirtioMemStartRequest, ()>(
6320            (&mut start_info, region_addr, plugged_block_size, region_size),
6321            0x66dd64f17fb5223c,
6322            fidl::encoding::DynamicFlags::empty(),
6323            _decode,
6324        )
6325    }
6326}
6327
6328pub struct VirtioMemEventStream {
6329    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6330}
6331
6332impl std::marker::Unpin for VirtioMemEventStream {}
6333
6334impl futures::stream::FusedStream for VirtioMemEventStream {
6335    fn is_terminated(&self) -> bool {
6336        self.event_receiver.is_terminated()
6337    }
6338}
6339
6340impl futures::Stream for VirtioMemEventStream {
6341    type Item = Result<VirtioMemEvent, fidl::Error>;
6342
6343    fn poll_next(
6344        mut self: std::pin::Pin<&mut Self>,
6345        cx: &mut std::task::Context<'_>,
6346    ) -> std::task::Poll<Option<Self::Item>> {
6347        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6348            &mut self.event_receiver,
6349            cx
6350        )?) {
6351            Some(buf) => std::task::Poll::Ready(Some(VirtioMemEvent::decode(buf))),
6352            None => std::task::Poll::Ready(None),
6353        }
6354    }
6355}
6356
6357#[derive(Debug)]
6358pub enum VirtioMemEvent {
6359    OnConfigChanged { plugged_size: u64 },
6360}
6361
6362impl VirtioMemEvent {
6363    #[allow(irrefutable_let_patterns)]
6364    pub fn into_on_config_changed(self) -> Option<u64> {
6365        if let VirtioMemEvent::OnConfigChanged { plugged_size } = self {
6366            Some((plugged_size))
6367        } else {
6368            None
6369        }
6370    }
6371
6372    /// Decodes a message buffer as a [`VirtioMemEvent`].
6373    fn decode(
6374        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6375    ) -> Result<VirtioMemEvent, fidl::Error> {
6376        let (bytes, _handles) = buf.split_mut();
6377        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6378        debug_assert_eq!(tx_header.tx_id, 0);
6379        match tx_header.ordinal {
6380            0x73b86d7cc80020b9 => {
6381                let mut out = fidl::new_empty!(
6382                    VirtioMemOnConfigChangedRequest,
6383                    fidl::encoding::DefaultFuchsiaResourceDialect
6384                );
6385                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMemOnConfigChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6386                Ok((VirtioMemEvent::OnConfigChanged { plugged_size: out.plugged_size }))
6387            }
6388            _ => Err(fidl::Error::UnknownOrdinal {
6389                ordinal: tx_header.ordinal,
6390                protocol_name: <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6391            }),
6392        }
6393    }
6394}
6395
6396/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioMem.
6397pub struct VirtioMemRequestStream {
6398    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6399    is_terminated: bool,
6400}
6401
6402impl std::marker::Unpin for VirtioMemRequestStream {}
6403
6404impl futures::stream::FusedStream for VirtioMemRequestStream {
6405    fn is_terminated(&self) -> bool {
6406        self.is_terminated
6407    }
6408}
6409
6410impl fidl::endpoints::RequestStream for VirtioMemRequestStream {
6411    type Protocol = VirtioMemMarker;
6412    type ControlHandle = VirtioMemControlHandle;
6413
6414    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6415        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6416    }
6417
6418    fn control_handle(&self) -> Self::ControlHandle {
6419        VirtioMemControlHandle { inner: self.inner.clone() }
6420    }
6421
6422    fn into_inner(
6423        self,
6424    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6425    {
6426        (self.inner, self.is_terminated)
6427    }
6428
6429    fn from_inner(
6430        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6431        is_terminated: bool,
6432    ) -> Self {
6433        Self { inner, is_terminated }
6434    }
6435}
6436
6437impl futures::Stream for VirtioMemRequestStream {
6438    type Item = Result<VirtioMemRequest, fidl::Error>;
6439
6440    fn poll_next(
6441        mut self: std::pin::Pin<&mut Self>,
6442        cx: &mut std::task::Context<'_>,
6443    ) -> std::task::Poll<Option<Self::Item>> {
6444        let this = &mut *self;
6445        if this.inner.check_shutdown(cx) {
6446            this.is_terminated = true;
6447            return std::task::Poll::Ready(None);
6448        }
6449        if this.is_terminated {
6450            panic!("polled VirtioMemRequestStream after completion");
6451        }
6452        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6453            |bytes, handles| {
6454                match this.inner.channel().read_etc(cx, bytes, handles) {
6455                    std::task::Poll::Ready(Ok(())) => {}
6456                    std::task::Poll::Pending => return std::task::Poll::Pending,
6457                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6458                        this.is_terminated = true;
6459                        return std::task::Poll::Ready(None);
6460                    }
6461                    std::task::Poll::Ready(Err(e)) => {
6462                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6463                            e.into(),
6464                        ))))
6465                    }
6466                }
6467
6468                // A message has been received from the channel
6469                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6470
6471                std::task::Poll::Ready(Some(match header.ordinal {
6472                    0x72b44fb963480b11 => {
6473                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6474                        let mut req = fidl::new_empty!(
6475                            VirtioDeviceConfigureQueueRequest,
6476                            fidl::encoding::DefaultFuchsiaResourceDialect
6477                        );
6478                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
6479                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
6480                        Ok(VirtioMemRequest::ConfigureQueue {
6481                            queue: req.queue,
6482                            size: req.size,
6483                            desc: req.desc,
6484                            avail: req.avail,
6485                            used: req.used,
6486
6487                            responder: VirtioMemConfigureQueueResponder {
6488                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6489                                tx_id: header.tx_id,
6490                            },
6491                        })
6492                    }
6493                    0x6e3a61d652499244 => {
6494                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6495                        let mut req = fidl::new_empty!(
6496                            VirtioDeviceNotifyQueueRequest,
6497                            fidl::encoding::DefaultFuchsiaResourceDialect
6498                        );
6499                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
6500                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
6501                        Ok(VirtioMemRequest::NotifyQueue { queue: req.queue, control_handle })
6502                    }
6503                    0x45707654f5d23c3f => {
6504                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6505                        let mut req = fidl::new_empty!(
6506                            VirtioDeviceReadyRequest,
6507                            fidl::encoding::DefaultFuchsiaResourceDialect
6508                        );
6509                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
6510                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
6511                        Ok(VirtioMemRequest::Ready {
6512                            negotiated_features: req.negotiated_features,
6513
6514                            responder: VirtioMemReadyResponder {
6515                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6516                                tx_id: header.tx_id,
6517                            },
6518                        })
6519                    }
6520                    0x66dd64f17fb5223c => {
6521                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6522                        let mut req = fidl::new_empty!(
6523                            VirtioMemStartRequest,
6524                            fidl::encoding::DefaultFuchsiaResourceDialect
6525                        );
6526                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMemStartRequest>(&header, _body_bytes, handles, &mut req)?;
6527                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
6528                        Ok(VirtioMemRequest::Start {
6529                            start_info: req.start_info,
6530                            region_addr: req.region_addr,
6531                            plugged_block_size: req.plugged_block_size,
6532                            region_size: req.region_size,
6533
6534                            responder: VirtioMemStartResponder {
6535                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6536                                tx_id: header.tx_id,
6537                            },
6538                        })
6539                    }
6540                    _ => Err(fidl::Error::UnknownOrdinal {
6541                        ordinal: header.ordinal,
6542                        protocol_name:
6543                            <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6544                    }),
6545                }))
6546            },
6547        )
6548    }
6549}
6550
6551#[derive(Debug)]
6552pub enum VirtioMemRequest {
6553    /// Configure a `queue` for the device. This specifies the `size` and the
6554    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6555    ConfigureQueue {
6556        queue: u16,
6557        size: u16,
6558        desc: u64,
6559        avail: u64,
6560        used: u64,
6561        responder: VirtioMemConfigureQueueResponder,
6562    },
6563    /// Notify a `queue` for the device. Primarily used for black-box testing.
6564    NotifyQueue { queue: u16, control_handle: VirtioMemControlHandle },
6565    /// Ready a device. This provides the set of `negotiated_features` that the
6566    /// driver and device have agreed upon.
6567    Ready { negotiated_features: u32, responder: VirtioMemReadyResponder },
6568    /// Start the mem device.
6569    Start {
6570        start_info: StartInfo,
6571        region_addr: u64,
6572        plugged_block_size: u64,
6573        region_size: u64,
6574        responder: VirtioMemStartResponder,
6575    },
6576}
6577
6578impl VirtioMemRequest {
6579    #[allow(irrefutable_let_patterns)]
6580    pub fn into_configure_queue(
6581        self,
6582    ) -> Option<(u16, u16, u64, u64, u64, VirtioMemConfigureQueueResponder)> {
6583        if let VirtioMemRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
6584        {
6585            Some((queue, size, desc, avail, used, responder))
6586        } else {
6587            None
6588        }
6589    }
6590
6591    #[allow(irrefutable_let_patterns)]
6592    pub fn into_notify_queue(self) -> Option<(u16, VirtioMemControlHandle)> {
6593        if let VirtioMemRequest::NotifyQueue { queue, control_handle } = self {
6594            Some((queue, control_handle))
6595        } else {
6596            None
6597        }
6598    }
6599
6600    #[allow(irrefutable_let_patterns)]
6601    pub fn into_ready(self) -> Option<(u32, VirtioMemReadyResponder)> {
6602        if let VirtioMemRequest::Ready { negotiated_features, responder } = self {
6603            Some((negotiated_features, responder))
6604        } else {
6605            None
6606        }
6607    }
6608
6609    #[allow(irrefutable_let_patterns)]
6610    pub fn into_start(self) -> Option<(StartInfo, u64, u64, u64, VirtioMemStartResponder)> {
6611        if let VirtioMemRequest::Start {
6612            start_info,
6613            region_addr,
6614            plugged_block_size,
6615            region_size,
6616            responder,
6617        } = self
6618        {
6619            Some((start_info, region_addr, plugged_block_size, region_size, responder))
6620        } else {
6621            None
6622        }
6623    }
6624
6625    /// Name of the method defined in FIDL
6626    pub fn method_name(&self) -> &'static str {
6627        match *self {
6628            VirtioMemRequest::ConfigureQueue { .. } => "configure_queue",
6629            VirtioMemRequest::NotifyQueue { .. } => "notify_queue",
6630            VirtioMemRequest::Ready { .. } => "ready",
6631            VirtioMemRequest::Start { .. } => "start",
6632        }
6633    }
6634}
6635
6636#[derive(Debug, Clone)]
6637pub struct VirtioMemControlHandle {
6638    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6639}
6640
6641impl fidl::endpoints::ControlHandle for VirtioMemControlHandle {
6642    fn shutdown(&self) {
6643        self.inner.shutdown()
6644    }
6645    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6646        self.inner.shutdown_with_epitaph(status)
6647    }
6648
6649    fn is_closed(&self) -> bool {
6650        self.inner.channel().is_closed()
6651    }
6652    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6653        self.inner.channel().on_closed()
6654    }
6655
6656    #[cfg(target_os = "fuchsia")]
6657    fn signal_peer(
6658        &self,
6659        clear_mask: zx::Signals,
6660        set_mask: zx::Signals,
6661    ) -> Result<(), zx_status::Status> {
6662        use fidl::Peered;
6663        self.inner.channel().signal_peer(clear_mask, set_mask)
6664    }
6665}
6666
6667impl VirtioMemControlHandle {
6668    pub fn send_on_config_changed(&self, mut plugged_size: u64) -> Result<(), fidl::Error> {
6669        self.inner.send::<VirtioMemOnConfigChangedRequest>(
6670            (plugged_size,),
6671            0,
6672            0x73b86d7cc80020b9,
6673            fidl::encoding::DynamicFlags::empty(),
6674        )
6675    }
6676}
6677
6678#[must_use = "FIDL methods require a response to be sent"]
6679#[derive(Debug)]
6680pub struct VirtioMemConfigureQueueResponder {
6681    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
6682    tx_id: u32,
6683}
6684
6685/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
6686/// if the responder is dropped without sending a response, so that the client
6687/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6688impl std::ops::Drop for VirtioMemConfigureQueueResponder {
6689    fn drop(&mut self) {
6690        self.control_handle.shutdown();
6691        // Safety: drops once, never accessed again
6692        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6693    }
6694}
6695
6696impl fidl::endpoints::Responder for VirtioMemConfigureQueueResponder {
6697    type ControlHandle = VirtioMemControlHandle;
6698
6699    fn control_handle(&self) -> &VirtioMemControlHandle {
6700        &self.control_handle
6701    }
6702
6703    fn drop_without_shutdown(mut self) {
6704        // Safety: drops once, never accessed again due to mem::forget
6705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6706        // Prevent Drop from running (which would shut down the channel)
6707        std::mem::forget(self);
6708    }
6709}
6710
6711impl VirtioMemConfigureQueueResponder {
6712    /// Sends a response to the FIDL transaction.
6713    ///
6714    /// Sets the channel to shutdown if an error occurs.
6715    pub fn send(self) -> Result<(), fidl::Error> {
6716        let _result = self.send_raw();
6717        if _result.is_err() {
6718            self.control_handle.shutdown();
6719        }
6720        self.drop_without_shutdown();
6721        _result
6722    }
6723
6724    /// Similar to "send" but does not shutdown the channel if an error occurs.
6725    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6726        let _result = self.send_raw();
6727        self.drop_without_shutdown();
6728        _result
6729    }
6730
6731    fn send_raw(&self) -> Result<(), fidl::Error> {
6732        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6733            (),
6734            self.tx_id,
6735            0x72b44fb963480b11,
6736            fidl::encoding::DynamicFlags::empty(),
6737        )
6738    }
6739}
6740
6741#[must_use = "FIDL methods require a response to be sent"]
6742#[derive(Debug)]
6743pub struct VirtioMemReadyResponder {
6744    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
6745    tx_id: u32,
6746}
6747
6748/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
6749/// if the responder is dropped without sending a response, so that the client
6750/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6751impl std::ops::Drop for VirtioMemReadyResponder {
6752    fn drop(&mut self) {
6753        self.control_handle.shutdown();
6754        // Safety: drops once, never accessed again
6755        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6756    }
6757}
6758
6759impl fidl::endpoints::Responder for VirtioMemReadyResponder {
6760    type ControlHandle = VirtioMemControlHandle;
6761
6762    fn control_handle(&self) -> &VirtioMemControlHandle {
6763        &self.control_handle
6764    }
6765
6766    fn drop_without_shutdown(mut self) {
6767        // Safety: drops once, never accessed again due to mem::forget
6768        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6769        // Prevent Drop from running (which would shut down the channel)
6770        std::mem::forget(self);
6771    }
6772}
6773
6774impl VirtioMemReadyResponder {
6775    /// Sends a response to the FIDL transaction.
6776    ///
6777    /// Sets the channel to shutdown if an error occurs.
6778    pub fn send(self) -> Result<(), fidl::Error> {
6779        let _result = self.send_raw();
6780        if _result.is_err() {
6781            self.control_handle.shutdown();
6782        }
6783        self.drop_without_shutdown();
6784        _result
6785    }
6786
6787    /// Similar to "send" but does not shutdown the channel if an error occurs.
6788    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6789        let _result = self.send_raw();
6790        self.drop_without_shutdown();
6791        _result
6792    }
6793
6794    fn send_raw(&self) -> Result<(), fidl::Error> {
6795        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6796            (),
6797            self.tx_id,
6798            0x45707654f5d23c3f,
6799            fidl::encoding::DynamicFlags::empty(),
6800        )
6801    }
6802}
6803
6804#[must_use = "FIDL methods require a response to be sent"]
6805#[derive(Debug)]
6806pub struct VirtioMemStartResponder {
6807    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
6808    tx_id: u32,
6809}
6810
6811/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
6812/// if the responder is dropped without sending a response, so that the client
6813/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6814impl std::ops::Drop for VirtioMemStartResponder {
6815    fn drop(&mut self) {
6816        self.control_handle.shutdown();
6817        // Safety: drops once, never accessed again
6818        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6819    }
6820}
6821
6822impl fidl::endpoints::Responder for VirtioMemStartResponder {
6823    type ControlHandle = VirtioMemControlHandle;
6824
6825    fn control_handle(&self) -> &VirtioMemControlHandle {
6826        &self.control_handle
6827    }
6828
6829    fn drop_without_shutdown(mut self) {
6830        // Safety: drops once, never accessed again due to mem::forget
6831        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6832        // Prevent Drop from running (which would shut down the channel)
6833        std::mem::forget(self);
6834    }
6835}
6836
6837impl VirtioMemStartResponder {
6838    /// Sends a response to the FIDL transaction.
6839    ///
6840    /// Sets the channel to shutdown if an error occurs.
6841    pub fn send(self) -> Result<(), fidl::Error> {
6842        let _result = self.send_raw();
6843        if _result.is_err() {
6844            self.control_handle.shutdown();
6845        }
6846        self.drop_without_shutdown();
6847        _result
6848    }
6849
6850    /// Similar to "send" but does not shutdown the channel if an error occurs.
6851    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6852        let _result = self.send_raw();
6853        self.drop_without_shutdown();
6854        _result
6855    }
6856
6857    fn send_raw(&self) -> Result<(), fidl::Error> {
6858        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6859            (),
6860            self.tx_id,
6861            0x66dd64f17fb5223c,
6862            fidl::encoding::DynamicFlags::empty(),
6863        )
6864    }
6865}
6866
6867#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6868pub struct VirtioNetMarker;
6869
6870impl fidl::endpoints::ProtocolMarker for VirtioNetMarker {
6871    type Proxy = VirtioNetProxy;
6872    type RequestStream = VirtioNetRequestStream;
6873    #[cfg(target_os = "fuchsia")]
6874    type SynchronousProxy = VirtioNetSynchronousProxy;
6875
6876    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioNet";
6877}
6878impl fidl::endpoints::DiscoverableProtocolMarker for VirtioNetMarker {}
6879pub type VirtioNetStartResult = Result<(), i32>;
6880
6881pub trait VirtioNetProxyInterface: Send + Sync {
6882    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6883    fn r#configure_queue(
6884        &self,
6885        queue: u16,
6886        size: u16,
6887        desc: u64,
6888        avail: u64,
6889        used: u64,
6890    ) -> Self::ConfigureQueueResponseFut;
6891    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
6892    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6893    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
6894    type StartResponseFut: std::future::Future<Output = Result<VirtioNetStartResult, fidl::Error>>
6895        + Send;
6896    fn r#start(
6897        &self,
6898        start_info: StartInfo,
6899        mac_address: &fidl_fuchsia_net::MacAddress,
6900        enable_bridge: bool,
6901    ) -> Self::StartResponseFut;
6902}
6903#[derive(Debug)]
6904#[cfg(target_os = "fuchsia")]
6905pub struct VirtioNetSynchronousProxy {
6906    client: fidl::client::sync::Client,
6907}
6908
6909#[cfg(target_os = "fuchsia")]
6910impl fidl::endpoints::SynchronousProxy for VirtioNetSynchronousProxy {
6911    type Proxy = VirtioNetProxy;
6912    type Protocol = VirtioNetMarker;
6913
6914    fn from_channel(inner: fidl::Channel) -> Self {
6915        Self::new(inner)
6916    }
6917
6918    fn into_channel(self) -> fidl::Channel {
6919        self.client.into_channel()
6920    }
6921
6922    fn as_channel(&self) -> &fidl::Channel {
6923        self.client.as_channel()
6924    }
6925}
6926
6927#[cfg(target_os = "fuchsia")]
6928impl VirtioNetSynchronousProxy {
6929    pub fn new(channel: fidl::Channel) -> Self {
6930        let protocol_name = <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6931        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6932    }
6933
6934    pub fn into_channel(self) -> fidl::Channel {
6935        self.client.into_channel()
6936    }
6937
6938    /// Waits until an event arrives and returns it. It is safe for other
6939    /// threads to make concurrent requests while waiting for an event.
6940    pub fn wait_for_event(
6941        &self,
6942        deadline: zx::MonotonicInstant,
6943    ) -> Result<VirtioNetEvent, fidl::Error> {
6944        VirtioNetEvent::decode(self.client.wait_for_event(deadline)?)
6945    }
6946
6947    /// Configure a `queue` for the device. This specifies the `size` and the
6948    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6949    pub fn r#configure_queue(
6950        &self,
6951        mut queue: u16,
6952        mut size: u16,
6953        mut desc: u64,
6954        mut avail: u64,
6955        mut used: u64,
6956        ___deadline: zx::MonotonicInstant,
6957    ) -> Result<(), fidl::Error> {
6958        let _response = self
6959            .client
6960            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
6961                (queue, size, desc, avail, used),
6962                0x72b44fb963480b11,
6963                fidl::encoding::DynamicFlags::empty(),
6964                ___deadline,
6965            )?;
6966        Ok(_response)
6967    }
6968
6969    /// Notify a `queue` for the device. Primarily used for black-box testing.
6970    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6971        self.client.send::<VirtioDeviceNotifyQueueRequest>(
6972            (queue,),
6973            0x6e3a61d652499244,
6974            fidl::encoding::DynamicFlags::empty(),
6975        )
6976    }
6977
6978    /// Ready a device. This provides the set of `negotiated_features` that the
6979    /// driver and device have agreed upon.
6980    pub fn r#ready(
6981        &self,
6982        mut negotiated_features: u32,
6983        ___deadline: zx::MonotonicInstant,
6984    ) -> Result<(), fidl::Error> {
6985        let _response =
6986            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
6987                (negotiated_features,),
6988                0x45707654f5d23c3f,
6989                fidl::encoding::DynamicFlags::empty(),
6990                ___deadline,
6991            )?;
6992        Ok(_response)
6993    }
6994
6995    /// Start the net device.
6996    pub fn r#start(
6997        &self,
6998        mut start_info: StartInfo,
6999        mut mac_address: &fidl_fuchsia_net::MacAddress,
7000        mut enable_bridge: bool,
7001        ___deadline: zx::MonotonicInstant,
7002    ) -> Result<VirtioNetStartResult, fidl::Error> {
7003        let _response = self.client.send_query::<
7004            VirtioNetStartRequest,
7005            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
7006        >(
7007            (&mut start_info, mac_address, enable_bridge,),
7008            0x795c0b3a8461b3ed,
7009            fidl::encoding::DynamicFlags::empty(),
7010            ___deadline,
7011        )?;
7012        Ok(_response.map(|x| x))
7013    }
7014}
7015
7016#[cfg(target_os = "fuchsia")]
7017impl From<VirtioNetSynchronousProxy> for zx::Handle {
7018    fn from(value: VirtioNetSynchronousProxy) -> Self {
7019        value.into_channel().into()
7020    }
7021}
7022
7023#[cfg(target_os = "fuchsia")]
7024impl From<fidl::Channel> for VirtioNetSynchronousProxy {
7025    fn from(value: fidl::Channel) -> Self {
7026        Self::new(value)
7027    }
7028}
7029
7030#[derive(Debug, Clone)]
7031pub struct VirtioNetProxy {
7032    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7033}
7034
7035impl fidl::endpoints::Proxy for VirtioNetProxy {
7036    type Protocol = VirtioNetMarker;
7037
7038    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7039        Self::new(inner)
7040    }
7041
7042    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7043        self.client.into_channel().map_err(|client| Self { client })
7044    }
7045
7046    fn as_channel(&self) -> &::fidl::AsyncChannel {
7047        self.client.as_channel()
7048    }
7049}
7050
7051impl VirtioNetProxy {
7052    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioNet.
7053    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7054        let protocol_name = <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7055        Self { client: fidl::client::Client::new(channel, protocol_name) }
7056    }
7057
7058    /// Get a Stream of events from the remote end of the protocol.
7059    ///
7060    /// # Panics
7061    ///
7062    /// Panics if the event stream was already taken.
7063    pub fn take_event_stream(&self) -> VirtioNetEventStream {
7064        VirtioNetEventStream { event_receiver: self.client.take_event_receiver() }
7065    }
7066
7067    /// Configure a `queue` for the device. This specifies the `size` and the
7068    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7069    pub fn r#configure_queue(
7070        &self,
7071        mut queue: u16,
7072        mut size: u16,
7073        mut desc: u64,
7074        mut avail: u64,
7075        mut used: u64,
7076    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7077        VirtioNetProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
7078    }
7079
7080    /// Notify a `queue` for the device. Primarily used for black-box testing.
7081    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7082        VirtioNetProxyInterface::r#notify_queue(self, queue)
7083    }
7084
7085    /// Ready a device. This provides the set of `negotiated_features` that the
7086    /// driver and device have agreed upon.
7087    pub fn r#ready(
7088        &self,
7089        mut negotiated_features: u32,
7090    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7091        VirtioNetProxyInterface::r#ready(self, negotiated_features)
7092    }
7093
7094    /// Start the net device.
7095    pub fn r#start(
7096        &self,
7097        mut start_info: StartInfo,
7098        mut mac_address: &fidl_fuchsia_net::MacAddress,
7099        mut enable_bridge: bool,
7100    ) -> fidl::client::QueryResponseFut<
7101        VirtioNetStartResult,
7102        fidl::encoding::DefaultFuchsiaResourceDialect,
7103    > {
7104        VirtioNetProxyInterface::r#start(self, start_info, mac_address, enable_bridge)
7105    }
7106}
7107
7108impl VirtioNetProxyInterface for VirtioNetProxy {
7109    type ConfigureQueueResponseFut =
7110        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7111    fn r#configure_queue(
7112        &self,
7113        mut queue: u16,
7114        mut size: u16,
7115        mut desc: u64,
7116        mut avail: u64,
7117        mut used: u64,
7118    ) -> Self::ConfigureQueueResponseFut {
7119        fn _decode(
7120            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7121        ) -> Result<(), fidl::Error> {
7122            let _response = fidl::client::decode_transaction_body::<
7123                fidl::encoding::EmptyPayload,
7124                fidl::encoding::DefaultFuchsiaResourceDialect,
7125                0x72b44fb963480b11,
7126            >(_buf?)?;
7127            Ok(_response)
7128        }
7129        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
7130            (queue, size, desc, avail, used),
7131            0x72b44fb963480b11,
7132            fidl::encoding::DynamicFlags::empty(),
7133            _decode,
7134        )
7135    }
7136
7137    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7138        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7139            (queue,),
7140            0x6e3a61d652499244,
7141            fidl::encoding::DynamicFlags::empty(),
7142        )
7143    }
7144
7145    type ReadyResponseFut =
7146        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7147    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
7148        fn _decode(
7149            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7150        ) -> Result<(), fidl::Error> {
7151            let _response = fidl::client::decode_transaction_body::<
7152                fidl::encoding::EmptyPayload,
7153                fidl::encoding::DefaultFuchsiaResourceDialect,
7154                0x45707654f5d23c3f,
7155            >(_buf?)?;
7156            Ok(_response)
7157        }
7158        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
7159            (negotiated_features,),
7160            0x45707654f5d23c3f,
7161            fidl::encoding::DynamicFlags::empty(),
7162            _decode,
7163        )
7164    }
7165
7166    type StartResponseFut = fidl::client::QueryResponseFut<
7167        VirtioNetStartResult,
7168        fidl::encoding::DefaultFuchsiaResourceDialect,
7169    >;
7170    fn r#start(
7171        &self,
7172        mut start_info: StartInfo,
7173        mut mac_address: &fidl_fuchsia_net::MacAddress,
7174        mut enable_bridge: bool,
7175    ) -> Self::StartResponseFut {
7176        fn _decode(
7177            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7178        ) -> Result<VirtioNetStartResult, fidl::Error> {
7179            let _response = fidl::client::decode_transaction_body::<
7180                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
7181                fidl::encoding::DefaultFuchsiaResourceDialect,
7182                0x795c0b3a8461b3ed,
7183            >(_buf?)?;
7184            Ok(_response.map(|x| x))
7185        }
7186        self.client.send_query_and_decode::<VirtioNetStartRequest, VirtioNetStartResult>(
7187            (&mut start_info, mac_address, enable_bridge),
7188            0x795c0b3a8461b3ed,
7189            fidl::encoding::DynamicFlags::empty(),
7190            _decode,
7191        )
7192    }
7193}
7194
7195pub struct VirtioNetEventStream {
7196    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7197}
7198
7199impl std::marker::Unpin for VirtioNetEventStream {}
7200
7201impl futures::stream::FusedStream for VirtioNetEventStream {
7202    fn is_terminated(&self) -> bool {
7203        self.event_receiver.is_terminated()
7204    }
7205}
7206
7207impl futures::Stream for VirtioNetEventStream {
7208    type Item = Result<VirtioNetEvent, fidl::Error>;
7209
7210    fn poll_next(
7211        mut self: std::pin::Pin<&mut Self>,
7212        cx: &mut std::task::Context<'_>,
7213    ) -> std::task::Poll<Option<Self::Item>> {
7214        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7215            &mut self.event_receiver,
7216            cx
7217        )?) {
7218            Some(buf) => std::task::Poll::Ready(Some(VirtioNetEvent::decode(buf))),
7219            None => std::task::Poll::Ready(None),
7220        }
7221    }
7222}
7223
7224#[derive(Debug)]
7225pub enum VirtioNetEvent {}
7226
7227impl VirtioNetEvent {
7228    /// Decodes a message buffer as a [`VirtioNetEvent`].
7229    fn decode(
7230        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7231    ) -> Result<VirtioNetEvent, fidl::Error> {
7232        let (bytes, _handles) = buf.split_mut();
7233        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7234        debug_assert_eq!(tx_header.tx_id, 0);
7235        match tx_header.ordinal {
7236            _ => Err(fidl::Error::UnknownOrdinal {
7237                ordinal: tx_header.ordinal,
7238                protocol_name: <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7239            }),
7240        }
7241    }
7242}
7243
7244/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioNet.
7245pub struct VirtioNetRequestStream {
7246    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7247    is_terminated: bool,
7248}
7249
7250impl std::marker::Unpin for VirtioNetRequestStream {}
7251
7252impl futures::stream::FusedStream for VirtioNetRequestStream {
7253    fn is_terminated(&self) -> bool {
7254        self.is_terminated
7255    }
7256}
7257
7258impl fidl::endpoints::RequestStream for VirtioNetRequestStream {
7259    type Protocol = VirtioNetMarker;
7260    type ControlHandle = VirtioNetControlHandle;
7261
7262    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7263        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7264    }
7265
7266    fn control_handle(&self) -> Self::ControlHandle {
7267        VirtioNetControlHandle { inner: self.inner.clone() }
7268    }
7269
7270    fn into_inner(
7271        self,
7272    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7273    {
7274        (self.inner, self.is_terminated)
7275    }
7276
7277    fn from_inner(
7278        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7279        is_terminated: bool,
7280    ) -> Self {
7281        Self { inner, is_terminated }
7282    }
7283}
7284
7285impl futures::Stream for VirtioNetRequestStream {
7286    type Item = Result<VirtioNetRequest, fidl::Error>;
7287
7288    fn poll_next(
7289        mut self: std::pin::Pin<&mut Self>,
7290        cx: &mut std::task::Context<'_>,
7291    ) -> std::task::Poll<Option<Self::Item>> {
7292        let this = &mut *self;
7293        if this.inner.check_shutdown(cx) {
7294            this.is_terminated = true;
7295            return std::task::Poll::Ready(None);
7296        }
7297        if this.is_terminated {
7298            panic!("polled VirtioNetRequestStream after completion");
7299        }
7300        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7301            |bytes, handles| {
7302                match this.inner.channel().read_etc(cx, bytes, handles) {
7303                    std::task::Poll::Ready(Ok(())) => {}
7304                    std::task::Poll::Pending => return std::task::Poll::Pending,
7305                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7306                        this.is_terminated = true;
7307                        return std::task::Poll::Ready(None);
7308                    }
7309                    std::task::Poll::Ready(Err(e)) => {
7310                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7311                            e.into(),
7312                        ))))
7313                    }
7314                }
7315
7316                // A message has been received from the channel
7317                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7318
7319                std::task::Poll::Ready(Some(match header.ordinal {
7320                    0x72b44fb963480b11 => {
7321                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7322                        let mut req = fidl::new_empty!(
7323                            VirtioDeviceConfigureQueueRequest,
7324                            fidl::encoding::DefaultFuchsiaResourceDialect
7325                        );
7326                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
7327                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
7328                        Ok(VirtioNetRequest::ConfigureQueue {
7329                            queue: req.queue,
7330                            size: req.size,
7331                            desc: req.desc,
7332                            avail: req.avail,
7333                            used: req.used,
7334
7335                            responder: VirtioNetConfigureQueueResponder {
7336                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7337                                tx_id: header.tx_id,
7338                            },
7339                        })
7340                    }
7341                    0x6e3a61d652499244 => {
7342                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7343                        let mut req = fidl::new_empty!(
7344                            VirtioDeviceNotifyQueueRequest,
7345                            fidl::encoding::DefaultFuchsiaResourceDialect
7346                        );
7347                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
7348                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
7349                        Ok(VirtioNetRequest::NotifyQueue { queue: req.queue, control_handle })
7350                    }
7351                    0x45707654f5d23c3f => {
7352                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7353                        let mut req = fidl::new_empty!(
7354                            VirtioDeviceReadyRequest,
7355                            fidl::encoding::DefaultFuchsiaResourceDialect
7356                        );
7357                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
7358                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
7359                        Ok(VirtioNetRequest::Ready {
7360                            negotiated_features: req.negotiated_features,
7361
7362                            responder: VirtioNetReadyResponder {
7363                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7364                                tx_id: header.tx_id,
7365                            },
7366                        })
7367                    }
7368                    0x795c0b3a8461b3ed => {
7369                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7370                        let mut req = fidl::new_empty!(
7371                            VirtioNetStartRequest,
7372                            fidl::encoding::DefaultFuchsiaResourceDialect
7373                        );
7374                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioNetStartRequest>(&header, _body_bytes, handles, &mut req)?;
7375                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
7376                        Ok(VirtioNetRequest::Start {
7377                            start_info: req.start_info,
7378                            mac_address: req.mac_address,
7379                            enable_bridge: req.enable_bridge,
7380
7381                            responder: VirtioNetStartResponder {
7382                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7383                                tx_id: header.tx_id,
7384                            },
7385                        })
7386                    }
7387                    _ => Err(fidl::Error::UnknownOrdinal {
7388                        ordinal: header.ordinal,
7389                        protocol_name:
7390                            <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7391                    }),
7392                }))
7393            },
7394        )
7395    }
7396}
7397
7398#[derive(Debug)]
7399pub enum VirtioNetRequest {
7400    /// Configure a `queue` for the device. This specifies the `size` and the
7401    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7402    ConfigureQueue {
7403        queue: u16,
7404        size: u16,
7405        desc: u64,
7406        avail: u64,
7407        used: u64,
7408        responder: VirtioNetConfigureQueueResponder,
7409    },
7410    /// Notify a `queue` for the device. Primarily used for black-box testing.
7411    NotifyQueue { queue: u16, control_handle: VirtioNetControlHandle },
7412    /// Ready a device. This provides the set of `negotiated_features` that the
7413    /// driver and device have agreed upon.
7414    Ready { negotiated_features: u32, responder: VirtioNetReadyResponder },
7415    /// Start the net device.
7416    Start {
7417        start_info: StartInfo,
7418        mac_address: fidl_fuchsia_net::MacAddress,
7419        enable_bridge: bool,
7420        responder: VirtioNetStartResponder,
7421    },
7422}
7423
7424impl VirtioNetRequest {
7425    #[allow(irrefutable_let_patterns)]
7426    pub fn into_configure_queue(
7427        self,
7428    ) -> Option<(u16, u16, u64, u64, u64, VirtioNetConfigureQueueResponder)> {
7429        if let VirtioNetRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
7430        {
7431            Some((queue, size, desc, avail, used, responder))
7432        } else {
7433            None
7434        }
7435    }
7436
7437    #[allow(irrefutable_let_patterns)]
7438    pub fn into_notify_queue(self) -> Option<(u16, VirtioNetControlHandle)> {
7439        if let VirtioNetRequest::NotifyQueue { queue, control_handle } = self {
7440            Some((queue, control_handle))
7441        } else {
7442            None
7443        }
7444    }
7445
7446    #[allow(irrefutable_let_patterns)]
7447    pub fn into_ready(self) -> Option<(u32, VirtioNetReadyResponder)> {
7448        if let VirtioNetRequest::Ready { negotiated_features, responder } = self {
7449            Some((negotiated_features, responder))
7450        } else {
7451            None
7452        }
7453    }
7454
7455    #[allow(irrefutable_let_patterns)]
7456    pub fn into_start(
7457        self,
7458    ) -> Option<(StartInfo, fidl_fuchsia_net::MacAddress, bool, VirtioNetStartResponder)> {
7459        if let VirtioNetRequest::Start { start_info, mac_address, enable_bridge, responder } = self
7460        {
7461            Some((start_info, mac_address, enable_bridge, responder))
7462        } else {
7463            None
7464        }
7465    }
7466
7467    /// Name of the method defined in FIDL
7468    pub fn method_name(&self) -> &'static str {
7469        match *self {
7470            VirtioNetRequest::ConfigureQueue { .. } => "configure_queue",
7471            VirtioNetRequest::NotifyQueue { .. } => "notify_queue",
7472            VirtioNetRequest::Ready { .. } => "ready",
7473            VirtioNetRequest::Start { .. } => "start",
7474        }
7475    }
7476}
7477
7478#[derive(Debug, Clone)]
7479pub struct VirtioNetControlHandle {
7480    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7481}
7482
7483impl fidl::endpoints::ControlHandle for VirtioNetControlHandle {
7484    fn shutdown(&self) {
7485        self.inner.shutdown()
7486    }
7487    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7488        self.inner.shutdown_with_epitaph(status)
7489    }
7490
7491    fn is_closed(&self) -> bool {
7492        self.inner.channel().is_closed()
7493    }
7494    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7495        self.inner.channel().on_closed()
7496    }
7497
7498    #[cfg(target_os = "fuchsia")]
7499    fn signal_peer(
7500        &self,
7501        clear_mask: zx::Signals,
7502        set_mask: zx::Signals,
7503    ) -> Result<(), zx_status::Status> {
7504        use fidl::Peered;
7505        self.inner.channel().signal_peer(clear_mask, set_mask)
7506    }
7507}
7508
7509impl VirtioNetControlHandle {}
7510
7511#[must_use = "FIDL methods require a response to be sent"]
7512#[derive(Debug)]
7513pub struct VirtioNetConfigureQueueResponder {
7514    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
7515    tx_id: u32,
7516}
7517
7518/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
7519/// if the responder is dropped without sending a response, so that the client
7520/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7521impl std::ops::Drop for VirtioNetConfigureQueueResponder {
7522    fn drop(&mut self) {
7523        self.control_handle.shutdown();
7524        // Safety: drops once, never accessed again
7525        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7526    }
7527}
7528
7529impl fidl::endpoints::Responder for VirtioNetConfigureQueueResponder {
7530    type ControlHandle = VirtioNetControlHandle;
7531
7532    fn control_handle(&self) -> &VirtioNetControlHandle {
7533        &self.control_handle
7534    }
7535
7536    fn drop_without_shutdown(mut self) {
7537        // Safety: drops once, never accessed again due to mem::forget
7538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7539        // Prevent Drop from running (which would shut down the channel)
7540        std::mem::forget(self);
7541    }
7542}
7543
7544impl VirtioNetConfigureQueueResponder {
7545    /// Sends a response to the FIDL transaction.
7546    ///
7547    /// Sets the channel to shutdown if an error occurs.
7548    pub fn send(self) -> Result<(), fidl::Error> {
7549        let _result = self.send_raw();
7550        if _result.is_err() {
7551            self.control_handle.shutdown();
7552        }
7553        self.drop_without_shutdown();
7554        _result
7555    }
7556
7557    /// Similar to "send" but does not shutdown the channel if an error occurs.
7558    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7559        let _result = self.send_raw();
7560        self.drop_without_shutdown();
7561        _result
7562    }
7563
7564    fn send_raw(&self) -> Result<(), fidl::Error> {
7565        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7566            (),
7567            self.tx_id,
7568            0x72b44fb963480b11,
7569            fidl::encoding::DynamicFlags::empty(),
7570        )
7571    }
7572}
7573
7574#[must_use = "FIDL methods require a response to be sent"]
7575#[derive(Debug)]
7576pub struct VirtioNetReadyResponder {
7577    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
7578    tx_id: u32,
7579}
7580
7581/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
7582/// if the responder is dropped without sending a response, so that the client
7583/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7584impl std::ops::Drop for VirtioNetReadyResponder {
7585    fn drop(&mut self) {
7586        self.control_handle.shutdown();
7587        // Safety: drops once, never accessed again
7588        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7589    }
7590}
7591
7592impl fidl::endpoints::Responder for VirtioNetReadyResponder {
7593    type ControlHandle = VirtioNetControlHandle;
7594
7595    fn control_handle(&self) -> &VirtioNetControlHandle {
7596        &self.control_handle
7597    }
7598
7599    fn drop_without_shutdown(mut self) {
7600        // Safety: drops once, never accessed again due to mem::forget
7601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7602        // Prevent Drop from running (which would shut down the channel)
7603        std::mem::forget(self);
7604    }
7605}
7606
7607impl VirtioNetReadyResponder {
7608    /// Sends a response to the FIDL transaction.
7609    ///
7610    /// Sets the channel to shutdown if an error occurs.
7611    pub fn send(self) -> Result<(), fidl::Error> {
7612        let _result = self.send_raw();
7613        if _result.is_err() {
7614            self.control_handle.shutdown();
7615        }
7616        self.drop_without_shutdown();
7617        _result
7618    }
7619
7620    /// Similar to "send" but does not shutdown the channel if an error occurs.
7621    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7622        let _result = self.send_raw();
7623        self.drop_without_shutdown();
7624        _result
7625    }
7626
7627    fn send_raw(&self) -> Result<(), fidl::Error> {
7628        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7629            (),
7630            self.tx_id,
7631            0x45707654f5d23c3f,
7632            fidl::encoding::DynamicFlags::empty(),
7633        )
7634    }
7635}
7636
7637#[must_use = "FIDL methods require a response to be sent"]
7638#[derive(Debug)]
7639pub struct VirtioNetStartResponder {
7640    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
7641    tx_id: u32,
7642}
7643
7644/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
7645/// if the responder is dropped without sending a response, so that the client
7646/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7647impl std::ops::Drop for VirtioNetStartResponder {
7648    fn drop(&mut self) {
7649        self.control_handle.shutdown();
7650        // Safety: drops once, never accessed again
7651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7652    }
7653}
7654
7655impl fidl::endpoints::Responder for VirtioNetStartResponder {
7656    type ControlHandle = VirtioNetControlHandle;
7657
7658    fn control_handle(&self) -> &VirtioNetControlHandle {
7659        &self.control_handle
7660    }
7661
7662    fn drop_without_shutdown(mut self) {
7663        // Safety: drops once, never accessed again due to mem::forget
7664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7665        // Prevent Drop from running (which would shut down the channel)
7666        std::mem::forget(self);
7667    }
7668}
7669
7670impl VirtioNetStartResponder {
7671    /// Sends a response to the FIDL transaction.
7672    ///
7673    /// Sets the channel to shutdown if an error occurs.
7674    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7675        let _result = self.send_raw(result);
7676        if _result.is_err() {
7677            self.control_handle.shutdown();
7678        }
7679        self.drop_without_shutdown();
7680        _result
7681    }
7682
7683    /// Similar to "send" but does not shutdown the channel if an error occurs.
7684    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7685        let _result = self.send_raw(result);
7686        self.drop_without_shutdown();
7687        _result
7688    }
7689
7690    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7691        self.control_handle
7692            .inner
7693            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
7694                result,
7695                self.tx_id,
7696                0x795c0b3a8461b3ed,
7697                fidl::encoding::DynamicFlags::empty(),
7698            )
7699    }
7700}
7701
7702#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7703pub struct VirtioRngMarker;
7704
7705impl fidl::endpoints::ProtocolMarker for VirtioRngMarker {
7706    type Proxy = VirtioRngProxy;
7707    type RequestStream = VirtioRngRequestStream;
7708    #[cfg(target_os = "fuchsia")]
7709    type SynchronousProxy = VirtioRngSynchronousProxy;
7710
7711    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioRng";
7712}
7713impl fidl::endpoints::DiscoverableProtocolMarker for VirtioRngMarker {}
7714
7715pub trait VirtioRngProxyInterface: Send + Sync {
7716    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7717    fn r#configure_queue(
7718        &self,
7719        queue: u16,
7720        size: u16,
7721        desc: u64,
7722        avail: u64,
7723        used: u64,
7724    ) -> Self::ConfigureQueueResponseFut;
7725    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
7726    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7727    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
7728    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7729    fn r#start(&self, start_info: StartInfo) -> Self::StartResponseFut;
7730}
7731#[derive(Debug)]
7732#[cfg(target_os = "fuchsia")]
7733pub struct VirtioRngSynchronousProxy {
7734    client: fidl::client::sync::Client,
7735}
7736
7737#[cfg(target_os = "fuchsia")]
7738impl fidl::endpoints::SynchronousProxy for VirtioRngSynchronousProxy {
7739    type Proxy = VirtioRngProxy;
7740    type Protocol = VirtioRngMarker;
7741
7742    fn from_channel(inner: fidl::Channel) -> Self {
7743        Self::new(inner)
7744    }
7745
7746    fn into_channel(self) -> fidl::Channel {
7747        self.client.into_channel()
7748    }
7749
7750    fn as_channel(&self) -> &fidl::Channel {
7751        self.client.as_channel()
7752    }
7753}
7754
7755#[cfg(target_os = "fuchsia")]
7756impl VirtioRngSynchronousProxy {
7757    pub fn new(channel: fidl::Channel) -> Self {
7758        let protocol_name = <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7759        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7760    }
7761
7762    pub fn into_channel(self) -> fidl::Channel {
7763        self.client.into_channel()
7764    }
7765
7766    /// Waits until an event arrives and returns it. It is safe for other
7767    /// threads to make concurrent requests while waiting for an event.
7768    pub fn wait_for_event(
7769        &self,
7770        deadline: zx::MonotonicInstant,
7771    ) -> Result<VirtioRngEvent, fidl::Error> {
7772        VirtioRngEvent::decode(self.client.wait_for_event(deadline)?)
7773    }
7774
7775    /// Configure a `queue` for the device. This specifies the `size` and the
7776    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7777    pub fn r#configure_queue(
7778        &self,
7779        mut queue: u16,
7780        mut size: u16,
7781        mut desc: u64,
7782        mut avail: u64,
7783        mut used: u64,
7784        ___deadline: zx::MonotonicInstant,
7785    ) -> Result<(), fidl::Error> {
7786        let _response = self
7787            .client
7788            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
7789                (queue, size, desc, avail, used),
7790                0x72b44fb963480b11,
7791                fidl::encoding::DynamicFlags::empty(),
7792                ___deadline,
7793            )?;
7794        Ok(_response)
7795    }
7796
7797    /// Notify a `queue` for the device. Primarily used for black-box testing.
7798    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7799        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7800            (queue,),
7801            0x6e3a61d652499244,
7802            fidl::encoding::DynamicFlags::empty(),
7803        )
7804    }
7805
7806    /// Ready a device. This provides the set of `negotiated_features` that the
7807    /// driver and device have agreed upon.
7808    pub fn r#ready(
7809        &self,
7810        mut negotiated_features: u32,
7811        ___deadline: zx::MonotonicInstant,
7812    ) -> Result<(), fidl::Error> {
7813        let _response =
7814            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
7815                (negotiated_features,),
7816                0x45707654f5d23c3f,
7817                fidl::encoding::DynamicFlags::empty(),
7818                ___deadline,
7819            )?;
7820        Ok(_response)
7821    }
7822
7823    /// Start the RNG device.
7824    pub fn r#start(
7825        &self,
7826        mut start_info: StartInfo,
7827        ___deadline: zx::MonotonicInstant,
7828    ) -> Result<(), fidl::Error> {
7829        let _response =
7830            self.client.send_query::<VirtioRngStartRequest, fidl::encoding::EmptyPayload>(
7831                (&mut start_info,),
7832                0x620b3ed254febc0f,
7833                fidl::encoding::DynamicFlags::empty(),
7834                ___deadline,
7835            )?;
7836        Ok(_response)
7837    }
7838}
7839
7840#[cfg(target_os = "fuchsia")]
7841impl From<VirtioRngSynchronousProxy> for zx::Handle {
7842    fn from(value: VirtioRngSynchronousProxy) -> Self {
7843        value.into_channel().into()
7844    }
7845}
7846
7847#[cfg(target_os = "fuchsia")]
7848impl From<fidl::Channel> for VirtioRngSynchronousProxy {
7849    fn from(value: fidl::Channel) -> Self {
7850        Self::new(value)
7851    }
7852}
7853
7854#[derive(Debug, Clone)]
7855pub struct VirtioRngProxy {
7856    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7857}
7858
7859impl fidl::endpoints::Proxy for VirtioRngProxy {
7860    type Protocol = VirtioRngMarker;
7861
7862    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7863        Self::new(inner)
7864    }
7865
7866    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7867        self.client.into_channel().map_err(|client| Self { client })
7868    }
7869
7870    fn as_channel(&self) -> &::fidl::AsyncChannel {
7871        self.client.as_channel()
7872    }
7873}
7874
7875impl VirtioRngProxy {
7876    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioRng.
7877    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7878        let protocol_name = <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7879        Self { client: fidl::client::Client::new(channel, protocol_name) }
7880    }
7881
7882    /// Get a Stream of events from the remote end of the protocol.
7883    ///
7884    /// # Panics
7885    ///
7886    /// Panics if the event stream was already taken.
7887    pub fn take_event_stream(&self) -> VirtioRngEventStream {
7888        VirtioRngEventStream { event_receiver: self.client.take_event_receiver() }
7889    }
7890
7891    /// Configure a `queue` for the device. This specifies the `size` and the
7892    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7893    pub fn r#configure_queue(
7894        &self,
7895        mut queue: u16,
7896        mut size: u16,
7897        mut desc: u64,
7898        mut avail: u64,
7899        mut used: u64,
7900    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7901        VirtioRngProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
7902    }
7903
7904    /// Notify a `queue` for the device. Primarily used for black-box testing.
7905    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7906        VirtioRngProxyInterface::r#notify_queue(self, queue)
7907    }
7908
7909    /// Ready a device. This provides the set of `negotiated_features` that the
7910    /// driver and device have agreed upon.
7911    pub fn r#ready(
7912        &self,
7913        mut negotiated_features: u32,
7914    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7915        VirtioRngProxyInterface::r#ready(self, negotiated_features)
7916    }
7917
7918    /// Start the RNG device.
7919    pub fn r#start(
7920        &self,
7921        mut start_info: StartInfo,
7922    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7923        VirtioRngProxyInterface::r#start(self, start_info)
7924    }
7925}
7926
7927impl VirtioRngProxyInterface for VirtioRngProxy {
7928    type ConfigureQueueResponseFut =
7929        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7930    fn r#configure_queue(
7931        &self,
7932        mut queue: u16,
7933        mut size: u16,
7934        mut desc: u64,
7935        mut avail: u64,
7936        mut used: u64,
7937    ) -> Self::ConfigureQueueResponseFut {
7938        fn _decode(
7939            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7940        ) -> Result<(), fidl::Error> {
7941            let _response = fidl::client::decode_transaction_body::<
7942                fidl::encoding::EmptyPayload,
7943                fidl::encoding::DefaultFuchsiaResourceDialect,
7944                0x72b44fb963480b11,
7945            >(_buf?)?;
7946            Ok(_response)
7947        }
7948        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
7949            (queue, size, desc, avail, used),
7950            0x72b44fb963480b11,
7951            fidl::encoding::DynamicFlags::empty(),
7952            _decode,
7953        )
7954    }
7955
7956    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7957        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7958            (queue,),
7959            0x6e3a61d652499244,
7960            fidl::encoding::DynamicFlags::empty(),
7961        )
7962    }
7963
7964    type ReadyResponseFut =
7965        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7966    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
7967        fn _decode(
7968            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7969        ) -> Result<(), fidl::Error> {
7970            let _response = fidl::client::decode_transaction_body::<
7971                fidl::encoding::EmptyPayload,
7972                fidl::encoding::DefaultFuchsiaResourceDialect,
7973                0x45707654f5d23c3f,
7974            >(_buf?)?;
7975            Ok(_response)
7976        }
7977        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
7978            (negotiated_features,),
7979            0x45707654f5d23c3f,
7980            fidl::encoding::DynamicFlags::empty(),
7981            _decode,
7982        )
7983    }
7984
7985    type StartResponseFut =
7986        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7987    fn r#start(&self, mut start_info: StartInfo) -> Self::StartResponseFut {
7988        fn _decode(
7989            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7990        ) -> Result<(), fidl::Error> {
7991            let _response = fidl::client::decode_transaction_body::<
7992                fidl::encoding::EmptyPayload,
7993                fidl::encoding::DefaultFuchsiaResourceDialect,
7994                0x620b3ed254febc0f,
7995            >(_buf?)?;
7996            Ok(_response)
7997        }
7998        self.client.send_query_and_decode::<VirtioRngStartRequest, ()>(
7999            (&mut start_info,),
8000            0x620b3ed254febc0f,
8001            fidl::encoding::DynamicFlags::empty(),
8002            _decode,
8003        )
8004    }
8005}
8006
8007pub struct VirtioRngEventStream {
8008    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8009}
8010
8011impl std::marker::Unpin for VirtioRngEventStream {}
8012
8013impl futures::stream::FusedStream for VirtioRngEventStream {
8014    fn is_terminated(&self) -> bool {
8015        self.event_receiver.is_terminated()
8016    }
8017}
8018
8019impl futures::Stream for VirtioRngEventStream {
8020    type Item = Result<VirtioRngEvent, fidl::Error>;
8021
8022    fn poll_next(
8023        mut self: std::pin::Pin<&mut Self>,
8024        cx: &mut std::task::Context<'_>,
8025    ) -> std::task::Poll<Option<Self::Item>> {
8026        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8027            &mut self.event_receiver,
8028            cx
8029        )?) {
8030            Some(buf) => std::task::Poll::Ready(Some(VirtioRngEvent::decode(buf))),
8031            None => std::task::Poll::Ready(None),
8032        }
8033    }
8034}
8035
8036#[derive(Debug)]
8037pub enum VirtioRngEvent {}
8038
8039impl VirtioRngEvent {
8040    /// Decodes a message buffer as a [`VirtioRngEvent`].
8041    fn decode(
8042        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8043    ) -> Result<VirtioRngEvent, fidl::Error> {
8044        let (bytes, _handles) = buf.split_mut();
8045        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8046        debug_assert_eq!(tx_header.tx_id, 0);
8047        match tx_header.ordinal {
8048            _ => Err(fidl::Error::UnknownOrdinal {
8049                ordinal: tx_header.ordinal,
8050                protocol_name: <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8051            }),
8052        }
8053    }
8054}
8055
8056/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioRng.
8057pub struct VirtioRngRequestStream {
8058    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8059    is_terminated: bool,
8060}
8061
8062impl std::marker::Unpin for VirtioRngRequestStream {}
8063
8064impl futures::stream::FusedStream for VirtioRngRequestStream {
8065    fn is_terminated(&self) -> bool {
8066        self.is_terminated
8067    }
8068}
8069
8070impl fidl::endpoints::RequestStream for VirtioRngRequestStream {
8071    type Protocol = VirtioRngMarker;
8072    type ControlHandle = VirtioRngControlHandle;
8073
8074    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8075        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8076    }
8077
8078    fn control_handle(&self) -> Self::ControlHandle {
8079        VirtioRngControlHandle { inner: self.inner.clone() }
8080    }
8081
8082    fn into_inner(
8083        self,
8084    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8085    {
8086        (self.inner, self.is_terminated)
8087    }
8088
8089    fn from_inner(
8090        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8091        is_terminated: bool,
8092    ) -> Self {
8093        Self { inner, is_terminated }
8094    }
8095}
8096
8097impl futures::Stream for VirtioRngRequestStream {
8098    type Item = Result<VirtioRngRequest, fidl::Error>;
8099
8100    fn poll_next(
8101        mut self: std::pin::Pin<&mut Self>,
8102        cx: &mut std::task::Context<'_>,
8103    ) -> std::task::Poll<Option<Self::Item>> {
8104        let this = &mut *self;
8105        if this.inner.check_shutdown(cx) {
8106            this.is_terminated = true;
8107            return std::task::Poll::Ready(None);
8108        }
8109        if this.is_terminated {
8110            panic!("polled VirtioRngRequestStream after completion");
8111        }
8112        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8113            |bytes, handles| {
8114                match this.inner.channel().read_etc(cx, bytes, handles) {
8115                    std::task::Poll::Ready(Ok(())) => {}
8116                    std::task::Poll::Pending => return std::task::Poll::Pending,
8117                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8118                        this.is_terminated = true;
8119                        return std::task::Poll::Ready(None);
8120                    }
8121                    std::task::Poll::Ready(Err(e)) => {
8122                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8123                            e.into(),
8124                        ))))
8125                    }
8126                }
8127
8128                // A message has been received from the channel
8129                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8130
8131                std::task::Poll::Ready(Some(match header.ordinal {
8132                    0x72b44fb963480b11 => {
8133                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8134                        let mut req = fidl::new_empty!(
8135                            VirtioDeviceConfigureQueueRequest,
8136                            fidl::encoding::DefaultFuchsiaResourceDialect
8137                        );
8138                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
8139                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
8140                        Ok(VirtioRngRequest::ConfigureQueue {
8141                            queue: req.queue,
8142                            size: req.size,
8143                            desc: req.desc,
8144                            avail: req.avail,
8145                            used: req.used,
8146
8147                            responder: VirtioRngConfigureQueueResponder {
8148                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8149                                tx_id: header.tx_id,
8150                            },
8151                        })
8152                    }
8153                    0x6e3a61d652499244 => {
8154                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8155                        let mut req = fidl::new_empty!(
8156                            VirtioDeviceNotifyQueueRequest,
8157                            fidl::encoding::DefaultFuchsiaResourceDialect
8158                        );
8159                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
8160                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
8161                        Ok(VirtioRngRequest::NotifyQueue { queue: req.queue, control_handle })
8162                    }
8163                    0x45707654f5d23c3f => {
8164                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8165                        let mut req = fidl::new_empty!(
8166                            VirtioDeviceReadyRequest,
8167                            fidl::encoding::DefaultFuchsiaResourceDialect
8168                        );
8169                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
8170                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
8171                        Ok(VirtioRngRequest::Ready {
8172                            negotiated_features: req.negotiated_features,
8173
8174                            responder: VirtioRngReadyResponder {
8175                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8176                                tx_id: header.tx_id,
8177                            },
8178                        })
8179                    }
8180                    0x620b3ed254febc0f => {
8181                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8182                        let mut req = fidl::new_empty!(
8183                            VirtioRngStartRequest,
8184                            fidl::encoding::DefaultFuchsiaResourceDialect
8185                        );
8186                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioRngStartRequest>(&header, _body_bytes, handles, &mut req)?;
8187                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
8188                        Ok(VirtioRngRequest::Start {
8189                            start_info: req.start_info,
8190
8191                            responder: VirtioRngStartResponder {
8192                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8193                                tx_id: header.tx_id,
8194                            },
8195                        })
8196                    }
8197                    _ => Err(fidl::Error::UnknownOrdinal {
8198                        ordinal: header.ordinal,
8199                        protocol_name:
8200                            <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8201                    }),
8202                }))
8203            },
8204        )
8205    }
8206}
8207
8208#[derive(Debug)]
8209pub enum VirtioRngRequest {
8210    /// Configure a `queue` for the device. This specifies the `size` and the
8211    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8212    ConfigureQueue {
8213        queue: u16,
8214        size: u16,
8215        desc: u64,
8216        avail: u64,
8217        used: u64,
8218        responder: VirtioRngConfigureQueueResponder,
8219    },
8220    /// Notify a `queue` for the device. Primarily used for black-box testing.
8221    NotifyQueue { queue: u16, control_handle: VirtioRngControlHandle },
8222    /// Ready a device. This provides the set of `negotiated_features` that the
8223    /// driver and device have agreed upon.
8224    Ready { negotiated_features: u32, responder: VirtioRngReadyResponder },
8225    /// Start the RNG device.
8226    Start { start_info: StartInfo, responder: VirtioRngStartResponder },
8227}
8228
8229impl VirtioRngRequest {
8230    #[allow(irrefutable_let_patterns)]
8231    pub fn into_configure_queue(
8232        self,
8233    ) -> Option<(u16, u16, u64, u64, u64, VirtioRngConfigureQueueResponder)> {
8234        if let VirtioRngRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
8235        {
8236            Some((queue, size, desc, avail, used, responder))
8237        } else {
8238            None
8239        }
8240    }
8241
8242    #[allow(irrefutable_let_patterns)]
8243    pub fn into_notify_queue(self) -> Option<(u16, VirtioRngControlHandle)> {
8244        if let VirtioRngRequest::NotifyQueue { queue, control_handle } = self {
8245            Some((queue, control_handle))
8246        } else {
8247            None
8248        }
8249    }
8250
8251    #[allow(irrefutable_let_patterns)]
8252    pub fn into_ready(self) -> Option<(u32, VirtioRngReadyResponder)> {
8253        if let VirtioRngRequest::Ready { negotiated_features, responder } = self {
8254            Some((negotiated_features, responder))
8255        } else {
8256            None
8257        }
8258    }
8259
8260    #[allow(irrefutable_let_patterns)]
8261    pub fn into_start(self) -> Option<(StartInfo, VirtioRngStartResponder)> {
8262        if let VirtioRngRequest::Start { start_info, responder } = self {
8263            Some((start_info, responder))
8264        } else {
8265            None
8266        }
8267    }
8268
8269    /// Name of the method defined in FIDL
8270    pub fn method_name(&self) -> &'static str {
8271        match *self {
8272            VirtioRngRequest::ConfigureQueue { .. } => "configure_queue",
8273            VirtioRngRequest::NotifyQueue { .. } => "notify_queue",
8274            VirtioRngRequest::Ready { .. } => "ready",
8275            VirtioRngRequest::Start { .. } => "start",
8276        }
8277    }
8278}
8279
8280#[derive(Debug, Clone)]
8281pub struct VirtioRngControlHandle {
8282    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8283}
8284
8285impl fidl::endpoints::ControlHandle for VirtioRngControlHandle {
8286    fn shutdown(&self) {
8287        self.inner.shutdown()
8288    }
8289    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8290        self.inner.shutdown_with_epitaph(status)
8291    }
8292
8293    fn is_closed(&self) -> bool {
8294        self.inner.channel().is_closed()
8295    }
8296    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8297        self.inner.channel().on_closed()
8298    }
8299
8300    #[cfg(target_os = "fuchsia")]
8301    fn signal_peer(
8302        &self,
8303        clear_mask: zx::Signals,
8304        set_mask: zx::Signals,
8305    ) -> Result<(), zx_status::Status> {
8306        use fidl::Peered;
8307        self.inner.channel().signal_peer(clear_mask, set_mask)
8308    }
8309}
8310
8311impl VirtioRngControlHandle {}
8312
8313#[must_use = "FIDL methods require a response to be sent"]
8314#[derive(Debug)]
8315pub struct VirtioRngConfigureQueueResponder {
8316    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
8317    tx_id: u32,
8318}
8319
8320/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
8321/// if the responder is dropped without sending a response, so that the client
8322/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8323impl std::ops::Drop for VirtioRngConfigureQueueResponder {
8324    fn drop(&mut self) {
8325        self.control_handle.shutdown();
8326        // Safety: drops once, never accessed again
8327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8328    }
8329}
8330
8331impl fidl::endpoints::Responder for VirtioRngConfigureQueueResponder {
8332    type ControlHandle = VirtioRngControlHandle;
8333
8334    fn control_handle(&self) -> &VirtioRngControlHandle {
8335        &self.control_handle
8336    }
8337
8338    fn drop_without_shutdown(mut self) {
8339        // Safety: drops once, never accessed again due to mem::forget
8340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8341        // Prevent Drop from running (which would shut down the channel)
8342        std::mem::forget(self);
8343    }
8344}
8345
8346impl VirtioRngConfigureQueueResponder {
8347    /// Sends a response to the FIDL transaction.
8348    ///
8349    /// Sets the channel to shutdown if an error occurs.
8350    pub fn send(self) -> Result<(), fidl::Error> {
8351        let _result = self.send_raw();
8352        if _result.is_err() {
8353            self.control_handle.shutdown();
8354        }
8355        self.drop_without_shutdown();
8356        _result
8357    }
8358
8359    /// Similar to "send" but does not shutdown the channel if an error occurs.
8360    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8361        let _result = self.send_raw();
8362        self.drop_without_shutdown();
8363        _result
8364    }
8365
8366    fn send_raw(&self) -> Result<(), fidl::Error> {
8367        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8368            (),
8369            self.tx_id,
8370            0x72b44fb963480b11,
8371            fidl::encoding::DynamicFlags::empty(),
8372        )
8373    }
8374}
8375
8376#[must_use = "FIDL methods require a response to be sent"]
8377#[derive(Debug)]
8378pub struct VirtioRngReadyResponder {
8379    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
8380    tx_id: u32,
8381}
8382
8383/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
8384/// if the responder is dropped without sending a response, so that the client
8385/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8386impl std::ops::Drop for VirtioRngReadyResponder {
8387    fn drop(&mut self) {
8388        self.control_handle.shutdown();
8389        // Safety: drops once, never accessed again
8390        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8391    }
8392}
8393
8394impl fidl::endpoints::Responder for VirtioRngReadyResponder {
8395    type ControlHandle = VirtioRngControlHandle;
8396
8397    fn control_handle(&self) -> &VirtioRngControlHandle {
8398        &self.control_handle
8399    }
8400
8401    fn drop_without_shutdown(mut self) {
8402        // Safety: drops once, never accessed again due to mem::forget
8403        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8404        // Prevent Drop from running (which would shut down the channel)
8405        std::mem::forget(self);
8406    }
8407}
8408
8409impl VirtioRngReadyResponder {
8410    /// Sends a response to the FIDL transaction.
8411    ///
8412    /// Sets the channel to shutdown if an error occurs.
8413    pub fn send(self) -> Result<(), fidl::Error> {
8414        let _result = self.send_raw();
8415        if _result.is_err() {
8416            self.control_handle.shutdown();
8417        }
8418        self.drop_without_shutdown();
8419        _result
8420    }
8421
8422    /// Similar to "send" but does not shutdown the channel if an error occurs.
8423    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8424        let _result = self.send_raw();
8425        self.drop_without_shutdown();
8426        _result
8427    }
8428
8429    fn send_raw(&self) -> Result<(), fidl::Error> {
8430        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8431            (),
8432            self.tx_id,
8433            0x45707654f5d23c3f,
8434            fidl::encoding::DynamicFlags::empty(),
8435        )
8436    }
8437}
8438
8439#[must_use = "FIDL methods require a response to be sent"]
8440#[derive(Debug)]
8441pub struct VirtioRngStartResponder {
8442    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
8443    tx_id: u32,
8444}
8445
8446/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
8447/// if the responder is dropped without sending a response, so that the client
8448/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8449impl std::ops::Drop for VirtioRngStartResponder {
8450    fn drop(&mut self) {
8451        self.control_handle.shutdown();
8452        // Safety: drops once, never accessed again
8453        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8454    }
8455}
8456
8457impl fidl::endpoints::Responder for VirtioRngStartResponder {
8458    type ControlHandle = VirtioRngControlHandle;
8459
8460    fn control_handle(&self) -> &VirtioRngControlHandle {
8461        &self.control_handle
8462    }
8463
8464    fn drop_without_shutdown(mut self) {
8465        // Safety: drops once, never accessed again due to mem::forget
8466        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8467        // Prevent Drop from running (which would shut down the channel)
8468        std::mem::forget(self);
8469    }
8470}
8471
8472impl VirtioRngStartResponder {
8473    /// Sends a response to the FIDL transaction.
8474    ///
8475    /// Sets the channel to shutdown if an error occurs.
8476    pub fn send(self) -> Result<(), fidl::Error> {
8477        let _result = self.send_raw();
8478        if _result.is_err() {
8479            self.control_handle.shutdown();
8480        }
8481        self.drop_without_shutdown();
8482        _result
8483    }
8484
8485    /// Similar to "send" but does not shutdown the channel if an error occurs.
8486    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8487        let _result = self.send_raw();
8488        self.drop_without_shutdown();
8489        _result
8490    }
8491
8492    fn send_raw(&self) -> Result<(), fidl::Error> {
8493        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8494            (),
8495            self.tx_id,
8496            0x620b3ed254febc0f,
8497            fidl::encoding::DynamicFlags::empty(),
8498        )
8499    }
8500}
8501
8502#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8503pub struct VirtioSoundMarker;
8504
8505impl fidl::endpoints::ProtocolMarker for VirtioSoundMarker {
8506    type Proxy = VirtioSoundProxy;
8507    type RequestStream = VirtioSoundRequestStream;
8508    #[cfg(target_os = "fuchsia")]
8509    type SynchronousProxy = VirtioSoundSynchronousProxy;
8510
8511    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioSound";
8512}
8513impl fidl::endpoints::DiscoverableProtocolMarker for VirtioSoundMarker {}
8514
8515pub trait VirtioSoundProxyInterface: Send + Sync {
8516    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8517    fn r#configure_queue(
8518        &self,
8519        queue: u16,
8520        size: u16,
8521        desc: u64,
8522        avail: u64,
8523        used: u64,
8524    ) -> Self::ConfigureQueueResponseFut;
8525    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
8526    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8527    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
8528    type StartResponseFut: std::future::Future<Output = Result<(u32, u32, u32, u32), fidl::Error>>
8529        + Send;
8530    fn r#start(
8531        &self,
8532        start_info: StartInfo,
8533        enable_input: bool,
8534        enable_verbose_logging: bool,
8535    ) -> Self::StartResponseFut;
8536}
8537#[derive(Debug)]
8538#[cfg(target_os = "fuchsia")]
8539pub struct VirtioSoundSynchronousProxy {
8540    client: fidl::client::sync::Client,
8541}
8542
8543#[cfg(target_os = "fuchsia")]
8544impl fidl::endpoints::SynchronousProxy for VirtioSoundSynchronousProxy {
8545    type Proxy = VirtioSoundProxy;
8546    type Protocol = VirtioSoundMarker;
8547
8548    fn from_channel(inner: fidl::Channel) -> Self {
8549        Self::new(inner)
8550    }
8551
8552    fn into_channel(self) -> fidl::Channel {
8553        self.client.into_channel()
8554    }
8555
8556    fn as_channel(&self) -> &fidl::Channel {
8557        self.client.as_channel()
8558    }
8559}
8560
8561#[cfg(target_os = "fuchsia")]
8562impl VirtioSoundSynchronousProxy {
8563    pub fn new(channel: fidl::Channel) -> Self {
8564        let protocol_name = <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8565        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8566    }
8567
8568    pub fn into_channel(self) -> fidl::Channel {
8569        self.client.into_channel()
8570    }
8571
8572    /// Waits until an event arrives and returns it. It is safe for other
8573    /// threads to make concurrent requests while waiting for an event.
8574    pub fn wait_for_event(
8575        &self,
8576        deadline: zx::MonotonicInstant,
8577    ) -> Result<VirtioSoundEvent, fidl::Error> {
8578        VirtioSoundEvent::decode(self.client.wait_for_event(deadline)?)
8579    }
8580
8581    /// Configure a `queue` for the device. This specifies the `size` and the
8582    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8583    pub fn r#configure_queue(
8584        &self,
8585        mut queue: u16,
8586        mut size: u16,
8587        mut desc: u64,
8588        mut avail: u64,
8589        mut used: u64,
8590        ___deadline: zx::MonotonicInstant,
8591    ) -> Result<(), fidl::Error> {
8592        let _response = self
8593            .client
8594            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
8595                (queue, size, desc, avail, used),
8596                0x72b44fb963480b11,
8597                fidl::encoding::DynamicFlags::empty(),
8598                ___deadline,
8599            )?;
8600        Ok(_response)
8601    }
8602
8603    /// Notify a `queue` for the device. Primarily used for black-box testing.
8604    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8605        self.client.send::<VirtioDeviceNotifyQueueRequest>(
8606            (queue,),
8607            0x6e3a61d652499244,
8608            fidl::encoding::DynamicFlags::empty(),
8609        )
8610    }
8611
8612    /// Ready a device. This provides the set of `negotiated_features` that the
8613    /// driver and device have agreed upon.
8614    pub fn r#ready(
8615        &self,
8616        mut negotiated_features: u32,
8617        ___deadline: zx::MonotonicInstant,
8618    ) -> Result<(), fidl::Error> {
8619        let _response =
8620            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
8621                (negotiated_features,),
8622                0x45707654f5d23c3f,
8623                fidl::encoding::DynamicFlags::empty(),
8624                ___deadline,
8625            )?;
8626        Ok(_response)
8627    }
8628
8629    /// Start the sound device.
8630    /// The response contains the device's expected static configuration.
8631    ///
8632    /// + request `start_info` basic info to start the device
8633    /// + request `enable_input` whether audio input (capture) should be enabled
8634    /// + request `enable_verbose_logging` whether verbose logging should be enabled
8635    /// - response `features` supported features
8636    /// - response `jacks` the virtio_snd_config.jacks value to advertise
8637    /// - response `streams` the virtio_snd_config.streams value to advertise
8638    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
8639    pub fn r#start(
8640        &self,
8641        mut start_info: StartInfo,
8642        mut enable_input: bool,
8643        mut enable_verbose_logging: bool,
8644        ___deadline: zx::MonotonicInstant,
8645    ) -> Result<(u32, u32, u32, u32), fidl::Error> {
8646        let _response =
8647            self.client.send_query::<VirtioSoundStartRequest, VirtioSoundStartResponse>(
8648                (&mut start_info, enable_input, enable_verbose_logging),
8649                0x2c3a5528c0b92e2d,
8650                fidl::encoding::DynamicFlags::empty(),
8651                ___deadline,
8652            )?;
8653        Ok((_response.features, _response.jacks, _response.streams, _response.chmaps))
8654    }
8655}
8656
8657#[cfg(target_os = "fuchsia")]
8658impl From<VirtioSoundSynchronousProxy> for zx::Handle {
8659    fn from(value: VirtioSoundSynchronousProxy) -> Self {
8660        value.into_channel().into()
8661    }
8662}
8663
8664#[cfg(target_os = "fuchsia")]
8665impl From<fidl::Channel> for VirtioSoundSynchronousProxy {
8666    fn from(value: fidl::Channel) -> Self {
8667        Self::new(value)
8668    }
8669}
8670
8671#[derive(Debug, Clone)]
8672pub struct VirtioSoundProxy {
8673    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8674}
8675
8676impl fidl::endpoints::Proxy for VirtioSoundProxy {
8677    type Protocol = VirtioSoundMarker;
8678
8679    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8680        Self::new(inner)
8681    }
8682
8683    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8684        self.client.into_channel().map_err(|client| Self { client })
8685    }
8686
8687    fn as_channel(&self) -> &::fidl::AsyncChannel {
8688        self.client.as_channel()
8689    }
8690}
8691
8692impl VirtioSoundProxy {
8693    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioSound.
8694    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8695        let protocol_name = <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8696        Self { client: fidl::client::Client::new(channel, protocol_name) }
8697    }
8698
8699    /// Get a Stream of events from the remote end of the protocol.
8700    ///
8701    /// # Panics
8702    ///
8703    /// Panics if the event stream was already taken.
8704    pub fn take_event_stream(&self) -> VirtioSoundEventStream {
8705        VirtioSoundEventStream { event_receiver: self.client.take_event_receiver() }
8706    }
8707
8708    /// Configure a `queue` for the device. This specifies the `size` and the
8709    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8710    pub fn r#configure_queue(
8711        &self,
8712        mut queue: u16,
8713        mut size: u16,
8714        mut desc: u64,
8715        mut avail: u64,
8716        mut used: u64,
8717    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8718        VirtioSoundProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
8719    }
8720
8721    /// Notify a `queue` for the device. Primarily used for black-box testing.
8722    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8723        VirtioSoundProxyInterface::r#notify_queue(self, queue)
8724    }
8725
8726    /// Ready a device. This provides the set of `negotiated_features` that the
8727    /// driver and device have agreed upon.
8728    pub fn r#ready(
8729        &self,
8730        mut negotiated_features: u32,
8731    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8732        VirtioSoundProxyInterface::r#ready(self, negotiated_features)
8733    }
8734
8735    /// Start the sound device.
8736    /// The response contains the device's expected static configuration.
8737    ///
8738    /// + request `start_info` basic info to start the device
8739    /// + request `enable_input` whether audio input (capture) should be enabled
8740    /// + request `enable_verbose_logging` whether verbose logging should be enabled
8741    /// - response `features` supported features
8742    /// - response `jacks` the virtio_snd_config.jacks value to advertise
8743    /// - response `streams` the virtio_snd_config.streams value to advertise
8744    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
8745    pub fn r#start(
8746        &self,
8747        mut start_info: StartInfo,
8748        mut enable_input: bool,
8749        mut enable_verbose_logging: bool,
8750    ) -> fidl::client::QueryResponseFut<
8751        (u32, u32, u32, u32),
8752        fidl::encoding::DefaultFuchsiaResourceDialect,
8753    > {
8754        VirtioSoundProxyInterface::r#start(self, start_info, enable_input, enable_verbose_logging)
8755    }
8756}
8757
8758impl VirtioSoundProxyInterface for VirtioSoundProxy {
8759    type ConfigureQueueResponseFut =
8760        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8761    fn r#configure_queue(
8762        &self,
8763        mut queue: u16,
8764        mut size: u16,
8765        mut desc: u64,
8766        mut avail: u64,
8767        mut used: u64,
8768    ) -> Self::ConfigureQueueResponseFut {
8769        fn _decode(
8770            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8771        ) -> Result<(), fidl::Error> {
8772            let _response = fidl::client::decode_transaction_body::<
8773                fidl::encoding::EmptyPayload,
8774                fidl::encoding::DefaultFuchsiaResourceDialect,
8775                0x72b44fb963480b11,
8776            >(_buf?)?;
8777            Ok(_response)
8778        }
8779        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
8780            (queue, size, desc, avail, used),
8781            0x72b44fb963480b11,
8782            fidl::encoding::DynamicFlags::empty(),
8783            _decode,
8784        )
8785    }
8786
8787    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8788        self.client.send::<VirtioDeviceNotifyQueueRequest>(
8789            (queue,),
8790            0x6e3a61d652499244,
8791            fidl::encoding::DynamicFlags::empty(),
8792        )
8793    }
8794
8795    type ReadyResponseFut =
8796        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8797    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
8798        fn _decode(
8799            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8800        ) -> Result<(), fidl::Error> {
8801            let _response = fidl::client::decode_transaction_body::<
8802                fidl::encoding::EmptyPayload,
8803                fidl::encoding::DefaultFuchsiaResourceDialect,
8804                0x45707654f5d23c3f,
8805            >(_buf?)?;
8806            Ok(_response)
8807        }
8808        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
8809            (negotiated_features,),
8810            0x45707654f5d23c3f,
8811            fidl::encoding::DynamicFlags::empty(),
8812            _decode,
8813        )
8814    }
8815
8816    type StartResponseFut = fidl::client::QueryResponseFut<
8817        (u32, u32, u32, u32),
8818        fidl::encoding::DefaultFuchsiaResourceDialect,
8819    >;
8820    fn r#start(
8821        &self,
8822        mut start_info: StartInfo,
8823        mut enable_input: bool,
8824        mut enable_verbose_logging: bool,
8825    ) -> Self::StartResponseFut {
8826        fn _decode(
8827            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8828        ) -> Result<(u32, u32, u32, u32), fidl::Error> {
8829            let _response = fidl::client::decode_transaction_body::<
8830                VirtioSoundStartResponse,
8831                fidl::encoding::DefaultFuchsiaResourceDialect,
8832                0x2c3a5528c0b92e2d,
8833            >(_buf?)?;
8834            Ok((_response.features, _response.jacks, _response.streams, _response.chmaps))
8835        }
8836        self.client.send_query_and_decode::<VirtioSoundStartRequest, (u32, u32, u32, u32)>(
8837            (&mut start_info, enable_input, enable_verbose_logging),
8838            0x2c3a5528c0b92e2d,
8839            fidl::encoding::DynamicFlags::empty(),
8840            _decode,
8841        )
8842    }
8843}
8844
8845pub struct VirtioSoundEventStream {
8846    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8847}
8848
8849impl std::marker::Unpin for VirtioSoundEventStream {}
8850
8851impl futures::stream::FusedStream for VirtioSoundEventStream {
8852    fn is_terminated(&self) -> bool {
8853        self.event_receiver.is_terminated()
8854    }
8855}
8856
8857impl futures::Stream for VirtioSoundEventStream {
8858    type Item = Result<VirtioSoundEvent, fidl::Error>;
8859
8860    fn poll_next(
8861        mut self: std::pin::Pin<&mut Self>,
8862        cx: &mut std::task::Context<'_>,
8863    ) -> std::task::Poll<Option<Self::Item>> {
8864        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8865            &mut self.event_receiver,
8866            cx
8867        )?) {
8868            Some(buf) => std::task::Poll::Ready(Some(VirtioSoundEvent::decode(buf))),
8869            None => std::task::Poll::Ready(None),
8870        }
8871    }
8872}
8873
8874#[derive(Debug)]
8875pub enum VirtioSoundEvent {}
8876
8877impl VirtioSoundEvent {
8878    /// Decodes a message buffer as a [`VirtioSoundEvent`].
8879    fn decode(
8880        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8881    ) -> Result<VirtioSoundEvent, fidl::Error> {
8882        let (bytes, _handles) = buf.split_mut();
8883        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8884        debug_assert_eq!(tx_header.tx_id, 0);
8885        match tx_header.ordinal {
8886            _ => Err(fidl::Error::UnknownOrdinal {
8887                ordinal: tx_header.ordinal,
8888                protocol_name: <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8889            }),
8890        }
8891    }
8892}
8893
8894/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioSound.
8895pub struct VirtioSoundRequestStream {
8896    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8897    is_terminated: bool,
8898}
8899
8900impl std::marker::Unpin for VirtioSoundRequestStream {}
8901
8902impl futures::stream::FusedStream for VirtioSoundRequestStream {
8903    fn is_terminated(&self) -> bool {
8904        self.is_terminated
8905    }
8906}
8907
8908impl fidl::endpoints::RequestStream for VirtioSoundRequestStream {
8909    type Protocol = VirtioSoundMarker;
8910    type ControlHandle = VirtioSoundControlHandle;
8911
8912    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8913        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8914    }
8915
8916    fn control_handle(&self) -> Self::ControlHandle {
8917        VirtioSoundControlHandle { inner: self.inner.clone() }
8918    }
8919
8920    fn into_inner(
8921        self,
8922    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8923    {
8924        (self.inner, self.is_terminated)
8925    }
8926
8927    fn from_inner(
8928        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8929        is_terminated: bool,
8930    ) -> Self {
8931        Self { inner, is_terminated }
8932    }
8933}
8934
8935impl futures::Stream for VirtioSoundRequestStream {
8936    type Item = Result<VirtioSoundRequest, fidl::Error>;
8937
8938    fn poll_next(
8939        mut self: std::pin::Pin<&mut Self>,
8940        cx: &mut std::task::Context<'_>,
8941    ) -> std::task::Poll<Option<Self::Item>> {
8942        let this = &mut *self;
8943        if this.inner.check_shutdown(cx) {
8944            this.is_terminated = true;
8945            return std::task::Poll::Ready(None);
8946        }
8947        if this.is_terminated {
8948            panic!("polled VirtioSoundRequestStream after completion");
8949        }
8950        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8951            |bytes, handles| {
8952                match this.inner.channel().read_etc(cx, bytes, handles) {
8953                    std::task::Poll::Ready(Ok(())) => {}
8954                    std::task::Poll::Pending => return std::task::Poll::Pending,
8955                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8956                        this.is_terminated = true;
8957                        return std::task::Poll::Ready(None);
8958                    }
8959                    std::task::Poll::Ready(Err(e)) => {
8960                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8961                            e.into(),
8962                        ))))
8963                    }
8964                }
8965
8966                // A message has been received from the channel
8967                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8968
8969                std::task::Poll::Ready(Some(match header.ordinal {
8970                    0x72b44fb963480b11 => {
8971                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8972                        let mut req = fidl::new_empty!(
8973                            VirtioDeviceConfigureQueueRequest,
8974                            fidl::encoding::DefaultFuchsiaResourceDialect
8975                        );
8976                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
8977                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
8978                        Ok(VirtioSoundRequest::ConfigureQueue {
8979                            queue: req.queue,
8980                            size: req.size,
8981                            desc: req.desc,
8982                            avail: req.avail,
8983                            used: req.used,
8984
8985                            responder: VirtioSoundConfigureQueueResponder {
8986                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8987                                tx_id: header.tx_id,
8988                            },
8989                        })
8990                    }
8991                    0x6e3a61d652499244 => {
8992                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8993                        let mut req = fidl::new_empty!(
8994                            VirtioDeviceNotifyQueueRequest,
8995                            fidl::encoding::DefaultFuchsiaResourceDialect
8996                        );
8997                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
8998                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
8999                        Ok(VirtioSoundRequest::NotifyQueue { queue: req.queue, control_handle })
9000                    }
9001                    0x45707654f5d23c3f => {
9002                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9003                        let mut req = fidl::new_empty!(
9004                            VirtioDeviceReadyRequest,
9005                            fidl::encoding::DefaultFuchsiaResourceDialect
9006                        );
9007                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
9008                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
9009                        Ok(VirtioSoundRequest::Ready {
9010                            negotiated_features: req.negotiated_features,
9011
9012                            responder: VirtioSoundReadyResponder {
9013                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9014                                tx_id: header.tx_id,
9015                            },
9016                        })
9017                    }
9018                    0x2c3a5528c0b92e2d => {
9019                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9020                        let mut req = fidl::new_empty!(
9021                            VirtioSoundStartRequest,
9022                            fidl::encoding::DefaultFuchsiaResourceDialect
9023                        );
9024                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioSoundStartRequest>(&header, _body_bytes, handles, &mut req)?;
9025                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
9026                        Ok(VirtioSoundRequest::Start {
9027                            start_info: req.start_info,
9028                            enable_input: req.enable_input,
9029                            enable_verbose_logging: req.enable_verbose_logging,
9030
9031                            responder: VirtioSoundStartResponder {
9032                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9033                                tx_id: header.tx_id,
9034                            },
9035                        })
9036                    }
9037                    _ => Err(fidl::Error::UnknownOrdinal {
9038                        ordinal: header.ordinal,
9039                        protocol_name:
9040                            <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9041                    }),
9042                }))
9043            },
9044        )
9045    }
9046}
9047
9048#[derive(Debug)]
9049pub enum VirtioSoundRequest {
9050    /// Configure a `queue` for the device. This specifies the `size` and the
9051    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
9052    ConfigureQueue {
9053        queue: u16,
9054        size: u16,
9055        desc: u64,
9056        avail: u64,
9057        used: u64,
9058        responder: VirtioSoundConfigureQueueResponder,
9059    },
9060    /// Notify a `queue` for the device. Primarily used for black-box testing.
9061    NotifyQueue { queue: u16, control_handle: VirtioSoundControlHandle },
9062    /// Ready a device. This provides the set of `negotiated_features` that the
9063    /// driver and device have agreed upon.
9064    Ready { negotiated_features: u32, responder: VirtioSoundReadyResponder },
9065    /// Start the sound device.
9066    /// The response contains the device's expected static configuration.
9067    ///
9068    /// + request `start_info` basic info to start the device
9069    /// + request `enable_input` whether audio input (capture) should be enabled
9070    /// + request `enable_verbose_logging` whether verbose logging should be enabled
9071    /// - response `features` supported features
9072    /// - response `jacks` the virtio_snd_config.jacks value to advertise
9073    /// - response `streams` the virtio_snd_config.streams value to advertise
9074    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
9075    Start {
9076        start_info: StartInfo,
9077        enable_input: bool,
9078        enable_verbose_logging: bool,
9079        responder: VirtioSoundStartResponder,
9080    },
9081}
9082
9083impl VirtioSoundRequest {
9084    #[allow(irrefutable_let_patterns)]
9085    pub fn into_configure_queue(
9086        self,
9087    ) -> Option<(u16, u16, u64, u64, u64, VirtioSoundConfigureQueueResponder)> {
9088        if let VirtioSoundRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
9089            self
9090        {
9091            Some((queue, size, desc, avail, used, responder))
9092        } else {
9093            None
9094        }
9095    }
9096
9097    #[allow(irrefutable_let_patterns)]
9098    pub fn into_notify_queue(self) -> Option<(u16, VirtioSoundControlHandle)> {
9099        if let VirtioSoundRequest::NotifyQueue { queue, control_handle } = self {
9100            Some((queue, control_handle))
9101        } else {
9102            None
9103        }
9104    }
9105
9106    #[allow(irrefutable_let_patterns)]
9107    pub fn into_ready(self) -> Option<(u32, VirtioSoundReadyResponder)> {
9108        if let VirtioSoundRequest::Ready { negotiated_features, responder } = self {
9109            Some((negotiated_features, responder))
9110        } else {
9111            None
9112        }
9113    }
9114
9115    #[allow(irrefutable_let_patterns)]
9116    pub fn into_start(self) -> Option<(StartInfo, bool, bool, VirtioSoundStartResponder)> {
9117        if let VirtioSoundRequest::Start {
9118            start_info,
9119            enable_input,
9120            enable_verbose_logging,
9121            responder,
9122        } = self
9123        {
9124            Some((start_info, enable_input, enable_verbose_logging, responder))
9125        } else {
9126            None
9127        }
9128    }
9129
9130    /// Name of the method defined in FIDL
9131    pub fn method_name(&self) -> &'static str {
9132        match *self {
9133            VirtioSoundRequest::ConfigureQueue { .. } => "configure_queue",
9134            VirtioSoundRequest::NotifyQueue { .. } => "notify_queue",
9135            VirtioSoundRequest::Ready { .. } => "ready",
9136            VirtioSoundRequest::Start { .. } => "start",
9137        }
9138    }
9139}
9140
9141#[derive(Debug, Clone)]
9142pub struct VirtioSoundControlHandle {
9143    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9144}
9145
9146impl fidl::endpoints::ControlHandle for VirtioSoundControlHandle {
9147    fn shutdown(&self) {
9148        self.inner.shutdown()
9149    }
9150    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9151        self.inner.shutdown_with_epitaph(status)
9152    }
9153
9154    fn is_closed(&self) -> bool {
9155        self.inner.channel().is_closed()
9156    }
9157    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9158        self.inner.channel().on_closed()
9159    }
9160
9161    #[cfg(target_os = "fuchsia")]
9162    fn signal_peer(
9163        &self,
9164        clear_mask: zx::Signals,
9165        set_mask: zx::Signals,
9166    ) -> Result<(), zx_status::Status> {
9167        use fidl::Peered;
9168        self.inner.channel().signal_peer(clear_mask, set_mask)
9169    }
9170}
9171
9172impl VirtioSoundControlHandle {}
9173
9174#[must_use = "FIDL methods require a response to be sent"]
9175#[derive(Debug)]
9176pub struct VirtioSoundConfigureQueueResponder {
9177    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
9178    tx_id: u32,
9179}
9180
9181/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
9182/// if the responder is dropped without sending a response, so that the client
9183/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9184impl std::ops::Drop for VirtioSoundConfigureQueueResponder {
9185    fn drop(&mut self) {
9186        self.control_handle.shutdown();
9187        // Safety: drops once, never accessed again
9188        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9189    }
9190}
9191
9192impl fidl::endpoints::Responder for VirtioSoundConfigureQueueResponder {
9193    type ControlHandle = VirtioSoundControlHandle;
9194
9195    fn control_handle(&self) -> &VirtioSoundControlHandle {
9196        &self.control_handle
9197    }
9198
9199    fn drop_without_shutdown(mut self) {
9200        // Safety: drops once, never accessed again due to mem::forget
9201        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9202        // Prevent Drop from running (which would shut down the channel)
9203        std::mem::forget(self);
9204    }
9205}
9206
9207impl VirtioSoundConfigureQueueResponder {
9208    /// Sends a response to the FIDL transaction.
9209    ///
9210    /// Sets the channel to shutdown if an error occurs.
9211    pub fn send(self) -> Result<(), fidl::Error> {
9212        let _result = self.send_raw();
9213        if _result.is_err() {
9214            self.control_handle.shutdown();
9215        }
9216        self.drop_without_shutdown();
9217        _result
9218    }
9219
9220    /// Similar to "send" but does not shutdown the channel if an error occurs.
9221    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9222        let _result = self.send_raw();
9223        self.drop_without_shutdown();
9224        _result
9225    }
9226
9227    fn send_raw(&self) -> Result<(), fidl::Error> {
9228        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9229            (),
9230            self.tx_id,
9231            0x72b44fb963480b11,
9232            fidl::encoding::DynamicFlags::empty(),
9233        )
9234    }
9235}
9236
9237#[must_use = "FIDL methods require a response to be sent"]
9238#[derive(Debug)]
9239pub struct VirtioSoundReadyResponder {
9240    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
9241    tx_id: u32,
9242}
9243
9244/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
9245/// if the responder is dropped without sending a response, so that the client
9246/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9247impl std::ops::Drop for VirtioSoundReadyResponder {
9248    fn drop(&mut self) {
9249        self.control_handle.shutdown();
9250        // Safety: drops once, never accessed again
9251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9252    }
9253}
9254
9255impl fidl::endpoints::Responder for VirtioSoundReadyResponder {
9256    type ControlHandle = VirtioSoundControlHandle;
9257
9258    fn control_handle(&self) -> &VirtioSoundControlHandle {
9259        &self.control_handle
9260    }
9261
9262    fn drop_without_shutdown(mut self) {
9263        // Safety: drops once, never accessed again due to mem::forget
9264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9265        // Prevent Drop from running (which would shut down the channel)
9266        std::mem::forget(self);
9267    }
9268}
9269
9270impl VirtioSoundReadyResponder {
9271    /// Sends a response to the FIDL transaction.
9272    ///
9273    /// Sets the channel to shutdown if an error occurs.
9274    pub fn send(self) -> Result<(), fidl::Error> {
9275        let _result = self.send_raw();
9276        if _result.is_err() {
9277            self.control_handle.shutdown();
9278        }
9279        self.drop_without_shutdown();
9280        _result
9281    }
9282
9283    /// Similar to "send" but does not shutdown the channel if an error occurs.
9284    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9285        let _result = self.send_raw();
9286        self.drop_without_shutdown();
9287        _result
9288    }
9289
9290    fn send_raw(&self) -> Result<(), fidl::Error> {
9291        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9292            (),
9293            self.tx_id,
9294            0x45707654f5d23c3f,
9295            fidl::encoding::DynamicFlags::empty(),
9296        )
9297    }
9298}
9299
9300#[must_use = "FIDL methods require a response to be sent"]
9301#[derive(Debug)]
9302pub struct VirtioSoundStartResponder {
9303    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
9304    tx_id: u32,
9305}
9306
9307/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
9308/// if the responder is dropped without sending a response, so that the client
9309/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9310impl std::ops::Drop for VirtioSoundStartResponder {
9311    fn drop(&mut self) {
9312        self.control_handle.shutdown();
9313        // Safety: drops once, never accessed again
9314        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9315    }
9316}
9317
9318impl fidl::endpoints::Responder for VirtioSoundStartResponder {
9319    type ControlHandle = VirtioSoundControlHandle;
9320
9321    fn control_handle(&self) -> &VirtioSoundControlHandle {
9322        &self.control_handle
9323    }
9324
9325    fn drop_without_shutdown(mut self) {
9326        // Safety: drops once, never accessed again due to mem::forget
9327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9328        // Prevent Drop from running (which would shut down the channel)
9329        std::mem::forget(self);
9330    }
9331}
9332
9333impl VirtioSoundStartResponder {
9334    /// Sends a response to the FIDL transaction.
9335    ///
9336    /// Sets the channel to shutdown if an error occurs.
9337    pub fn send(
9338        self,
9339        mut features: u32,
9340        mut jacks: u32,
9341        mut streams: u32,
9342        mut chmaps: u32,
9343    ) -> Result<(), fidl::Error> {
9344        let _result = self.send_raw(features, jacks, streams, chmaps);
9345        if _result.is_err() {
9346            self.control_handle.shutdown();
9347        }
9348        self.drop_without_shutdown();
9349        _result
9350    }
9351
9352    /// Similar to "send" but does not shutdown the channel if an error occurs.
9353    pub fn send_no_shutdown_on_err(
9354        self,
9355        mut features: u32,
9356        mut jacks: u32,
9357        mut streams: u32,
9358        mut chmaps: u32,
9359    ) -> Result<(), fidl::Error> {
9360        let _result = self.send_raw(features, jacks, streams, chmaps);
9361        self.drop_without_shutdown();
9362        _result
9363    }
9364
9365    fn send_raw(
9366        &self,
9367        mut features: u32,
9368        mut jacks: u32,
9369        mut streams: u32,
9370        mut chmaps: u32,
9371    ) -> Result<(), fidl::Error> {
9372        self.control_handle.inner.send::<VirtioSoundStartResponse>(
9373            (features, jacks, streams, chmaps),
9374            self.tx_id,
9375            0x2c3a5528c0b92e2d,
9376            fidl::encoding::DynamicFlags::empty(),
9377        )
9378    }
9379}
9380
9381#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9382pub struct VirtioVsockMarker;
9383
9384impl fidl::endpoints::ProtocolMarker for VirtioVsockMarker {
9385    type Proxy = VirtioVsockProxy;
9386    type RequestStream = VirtioVsockRequestStream;
9387    #[cfg(target_os = "fuchsia")]
9388    type SynchronousProxy = VirtioVsockSynchronousProxy;
9389
9390    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioVsock";
9391}
9392impl fidl::endpoints::DiscoverableProtocolMarker for VirtioVsockMarker {}
9393pub type VirtioVsockStartResult = Result<(), i32>;
9394
9395pub trait VirtioVsockProxyInterface: Send + Sync {
9396    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9397    fn r#configure_queue(
9398        &self,
9399        queue: u16,
9400        size: u16,
9401        desc: u64,
9402        avail: u64,
9403        used: u64,
9404    ) -> Self::ConfigureQueueResponseFut;
9405    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
9406    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9407    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
9408    type StartResponseFut: std::future::Future<Output = Result<VirtioVsockStartResult, fidl::Error>>
9409        + Send;
9410    fn r#start(
9411        &self,
9412        start_info: StartInfo,
9413        guest_cid: u32,
9414        listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9415    ) -> Self::StartResponseFut;
9416}
9417#[derive(Debug)]
9418#[cfg(target_os = "fuchsia")]
9419pub struct VirtioVsockSynchronousProxy {
9420    client: fidl::client::sync::Client,
9421}
9422
9423#[cfg(target_os = "fuchsia")]
9424impl fidl::endpoints::SynchronousProxy for VirtioVsockSynchronousProxy {
9425    type Proxy = VirtioVsockProxy;
9426    type Protocol = VirtioVsockMarker;
9427
9428    fn from_channel(inner: fidl::Channel) -> Self {
9429        Self::new(inner)
9430    }
9431
9432    fn into_channel(self) -> fidl::Channel {
9433        self.client.into_channel()
9434    }
9435
9436    fn as_channel(&self) -> &fidl::Channel {
9437        self.client.as_channel()
9438    }
9439}
9440
9441#[cfg(target_os = "fuchsia")]
9442impl VirtioVsockSynchronousProxy {
9443    pub fn new(channel: fidl::Channel) -> Self {
9444        let protocol_name = <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9445        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
9446    }
9447
9448    pub fn into_channel(self) -> fidl::Channel {
9449        self.client.into_channel()
9450    }
9451
9452    /// Waits until an event arrives and returns it. It is safe for other
9453    /// threads to make concurrent requests while waiting for an event.
9454    pub fn wait_for_event(
9455        &self,
9456        deadline: zx::MonotonicInstant,
9457    ) -> Result<VirtioVsockEvent, fidl::Error> {
9458        VirtioVsockEvent::decode(self.client.wait_for_event(deadline)?)
9459    }
9460
9461    /// Configure a `queue` for the device. This specifies the `size` and the
9462    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
9463    pub fn r#configure_queue(
9464        &self,
9465        mut queue: u16,
9466        mut size: u16,
9467        mut desc: u64,
9468        mut avail: u64,
9469        mut used: u64,
9470        ___deadline: zx::MonotonicInstant,
9471    ) -> Result<(), fidl::Error> {
9472        let _response = self
9473            .client
9474            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
9475                (queue, size, desc, avail, used),
9476                0x72b44fb963480b11,
9477                fidl::encoding::DynamicFlags::empty(),
9478                ___deadline,
9479            )?;
9480        Ok(_response)
9481    }
9482
9483    /// Notify a `queue` for the device. Primarily used for black-box testing.
9484    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
9485        self.client.send::<VirtioDeviceNotifyQueueRequest>(
9486            (queue,),
9487            0x6e3a61d652499244,
9488            fidl::encoding::DynamicFlags::empty(),
9489        )
9490    }
9491
9492    /// Ready a device. This provides the set of `negotiated_features` that the
9493    /// driver and device have agreed upon.
9494    pub fn r#ready(
9495        &self,
9496        mut negotiated_features: u32,
9497        ___deadline: zx::MonotonicInstant,
9498    ) -> Result<(), fidl::Error> {
9499        let _response =
9500            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
9501                (negotiated_features,),
9502                0x45707654f5d23c3f,
9503                fidl::encoding::DynamicFlags::empty(),
9504                ___deadline,
9505            )?;
9506        Ok(_response)
9507    }
9508
9509    /// Start the vsock device, setting the guest_cid to the provided value.
9510    ///
9511    /// Returns:
9512    ///   - ZX_OK if device startup succeeded
9513    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
9514    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
9515    pub fn r#start(
9516        &self,
9517        mut start_info: StartInfo,
9518        mut guest_cid: u32,
9519        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9520        ___deadline: zx::MonotonicInstant,
9521    ) -> Result<VirtioVsockStartResult, fidl::Error> {
9522        let _response = self.client.send_query::<
9523            VirtioVsockStartRequest,
9524            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
9525        >(
9526            (&mut start_info, guest_cid, listeners.as_mut(),),
9527            0x56433562cf67ae0f,
9528            fidl::encoding::DynamicFlags::empty(),
9529            ___deadline,
9530        )?;
9531        Ok(_response.map(|x| x))
9532    }
9533}
9534
9535#[cfg(target_os = "fuchsia")]
9536impl From<VirtioVsockSynchronousProxy> for zx::Handle {
9537    fn from(value: VirtioVsockSynchronousProxy) -> Self {
9538        value.into_channel().into()
9539    }
9540}
9541
9542#[cfg(target_os = "fuchsia")]
9543impl From<fidl::Channel> for VirtioVsockSynchronousProxy {
9544    fn from(value: fidl::Channel) -> Self {
9545        Self::new(value)
9546    }
9547}
9548
9549#[derive(Debug, Clone)]
9550pub struct VirtioVsockProxy {
9551    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9552}
9553
9554impl fidl::endpoints::Proxy for VirtioVsockProxy {
9555    type Protocol = VirtioVsockMarker;
9556
9557    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9558        Self::new(inner)
9559    }
9560
9561    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9562        self.client.into_channel().map_err(|client| Self { client })
9563    }
9564
9565    fn as_channel(&self) -> &::fidl::AsyncChannel {
9566        self.client.as_channel()
9567    }
9568}
9569
9570impl VirtioVsockProxy {
9571    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioVsock.
9572    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9573        let protocol_name = <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9574        Self { client: fidl::client::Client::new(channel, protocol_name) }
9575    }
9576
9577    /// Get a Stream of events from the remote end of the protocol.
9578    ///
9579    /// # Panics
9580    ///
9581    /// Panics if the event stream was already taken.
9582    pub fn take_event_stream(&self) -> VirtioVsockEventStream {
9583        VirtioVsockEventStream { event_receiver: self.client.take_event_receiver() }
9584    }
9585
9586    /// Configure a `queue` for the device. This specifies the `size` and the
9587    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
9588    pub fn r#configure_queue(
9589        &self,
9590        mut queue: u16,
9591        mut size: u16,
9592        mut desc: u64,
9593        mut avail: u64,
9594        mut used: u64,
9595    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
9596        VirtioVsockProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
9597    }
9598
9599    /// Notify a `queue` for the device. Primarily used for black-box testing.
9600    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
9601        VirtioVsockProxyInterface::r#notify_queue(self, queue)
9602    }
9603
9604    /// Ready a device. This provides the set of `negotiated_features` that the
9605    /// driver and device have agreed upon.
9606    pub fn r#ready(
9607        &self,
9608        mut negotiated_features: u32,
9609    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
9610        VirtioVsockProxyInterface::r#ready(self, negotiated_features)
9611    }
9612
9613    /// Start the vsock device, setting the guest_cid to the provided value.
9614    ///
9615    /// Returns:
9616    ///   - ZX_OK if device startup succeeded
9617    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
9618    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
9619    pub fn r#start(
9620        &self,
9621        mut start_info: StartInfo,
9622        mut guest_cid: u32,
9623        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9624    ) -> fidl::client::QueryResponseFut<
9625        VirtioVsockStartResult,
9626        fidl::encoding::DefaultFuchsiaResourceDialect,
9627    > {
9628        VirtioVsockProxyInterface::r#start(self, start_info, guest_cid, listeners)
9629    }
9630}
9631
9632impl VirtioVsockProxyInterface for VirtioVsockProxy {
9633    type ConfigureQueueResponseFut =
9634        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9635    fn r#configure_queue(
9636        &self,
9637        mut queue: u16,
9638        mut size: u16,
9639        mut desc: u64,
9640        mut avail: u64,
9641        mut used: u64,
9642    ) -> Self::ConfigureQueueResponseFut {
9643        fn _decode(
9644            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9645        ) -> Result<(), fidl::Error> {
9646            let _response = fidl::client::decode_transaction_body::<
9647                fidl::encoding::EmptyPayload,
9648                fidl::encoding::DefaultFuchsiaResourceDialect,
9649                0x72b44fb963480b11,
9650            >(_buf?)?;
9651            Ok(_response)
9652        }
9653        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
9654            (queue, size, desc, avail, used),
9655            0x72b44fb963480b11,
9656            fidl::encoding::DynamicFlags::empty(),
9657            _decode,
9658        )
9659    }
9660
9661    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
9662        self.client.send::<VirtioDeviceNotifyQueueRequest>(
9663            (queue,),
9664            0x6e3a61d652499244,
9665            fidl::encoding::DynamicFlags::empty(),
9666        )
9667    }
9668
9669    type ReadyResponseFut =
9670        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9671    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
9672        fn _decode(
9673            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9674        ) -> Result<(), fidl::Error> {
9675            let _response = fidl::client::decode_transaction_body::<
9676                fidl::encoding::EmptyPayload,
9677                fidl::encoding::DefaultFuchsiaResourceDialect,
9678                0x45707654f5d23c3f,
9679            >(_buf?)?;
9680            Ok(_response)
9681        }
9682        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
9683            (negotiated_features,),
9684            0x45707654f5d23c3f,
9685            fidl::encoding::DynamicFlags::empty(),
9686            _decode,
9687        )
9688    }
9689
9690    type StartResponseFut = fidl::client::QueryResponseFut<
9691        VirtioVsockStartResult,
9692        fidl::encoding::DefaultFuchsiaResourceDialect,
9693    >;
9694    fn r#start(
9695        &self,
9696        mut start_info: StartInfo,
9697        mut guest_cid: u32,
9698        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9699    ) -> Self::StartResponseFut {
9700        fn _decode(
9701            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9702        ) -> Result<VirtioVsockStartResult, fidl::Error> {
9703            let _response = fidl::client::decode_transaction_body::<
9704                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
9705                fidl::encoding::DefaultFuchsiaResourceDialect,
9706                0x56433562cf67ae0f,
9707            >(_buf?)?;
9708            Ok(_response.map(|x| x))
9709        }
9710        self.client.send_query_and_decode::<VirtioVsockStartRequest, VirtioVsockStartResult>(
9711            (&mut start_info, guest_cid, listeners.as_mut()),
9712            0x56433562cf67ae0f,
9713            fidl::encoding::DynamicFlags::empty(),
9714            _decode,
9715        )
9716    }
9717}
9718
9719pub struct VirtioVsockEventStream {
9720    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9721}
9722
9723impl std::marker::Unpin for VirtioVsockEventStream {}
9724
9725impl futures::stream::FusedStream for VirtioVsockEventStream {
9726    fn is_terminated(&self) -> bool {
9727        self.event_receiver.is_terminated()
9728    }
9729}
9730
9731impl futures::Stream for VirtioVsockEventStream {
9732    type Item = Result<VirtioVsockEvent, fidl::Error>;
9733
9734    fn poll_next(
9735        mut self: std::pin::Pin<&mut Self>,
9736        cx: &mut std::task::Context<'_>,
9737    ) -> std::task::Poll<Option<Self::Item>> {
9738        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9739            &mut self.event_receiver,
9740            cx
9741        )?) {
9742            Some(buf) => std::task::Poll::Ready(Some(VirtioVsockEvent::decode(buf))),
9743            None => std::task::Poll::Ready(None),
9744        }
9745    }
9746}
9747
9748#[derive(Debug)]
9749pub enum VirtioVsockEvent {}
9750
9751impl VirtioVsockEvent {
9752    /// Decodes a message buffer as a [`VirtioVsockEvent`].
9753    fn decode(
9754        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9755    ) -> Result<VirtioVsockEvent, fidl::Error> {
9756        let (bytes, _handles) = buf.split_mut();
9757        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9758        debug_assert_eq!(tx_header.tx_id, 0);
9759        match tx_header.ordinal {
9760            _ => Err(fidl::Error::UnknownOrdinal {
9761                ordinal: tx_header.ordinal,
9762                protocol_name: <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9763            }),
9764        }
9765    }
9766}
9767
9768/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioVsock.
9769pub struct VirtioVsockRequestStream {
9770    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9771    is_terminated: bool,
9772}
9773
9774impl std::marker::Unpin for VirtioVsockRequestStream {}
9775
9776impl futures::stream::FusedStream for VirtioVsockRequestStream {
9777    fn is_terminated(&self) -> bool {
9778        self.is_terminated
9779    }
9780}
9781
9782impl fidl::endpoints::RequestStream for VirtioVsockRequestStream {
9783    type Protocol = VirtioVsockMarker;
9784    type ControlHandle = VirtioVsockControlHandle;
9785
9786    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9787        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9788    }
9789
9790    fn control_handle(&self) -> Self::ControlHandle {
9791        VirtioVsockControlHandle { inner: self.inner.clone() }
9792    }
9793
9794    fn into_inner(
9795        self,
9796    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9797    {
9798        (self.inner, self.is_terminated)
9799    }
9800
9801    fn from_inner(
9802        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9803        is_terminated: bool,
9804    ) -> Self {
9805        Self { inner, is_terminated }
9806    }
9807}
9808
9809impl futures::Stream for VirtioVsockRequestStream {
9810    type Item = Result<VirtioVsockRequest, fidl::Error>;
9811
9812    fn poll_next(
9813        mut self: std::pin::Pin<&mut Self>,
9814        cx: &mut std::task::Context<'_>,
9815    ) -> std::task::Poll<Option<Self::Item>> {
9816        let this = &mut *self;
9817        if this.inner.check_shutdown(cx) {
9818            this.is_terminated = true;
9819            return std::task::Poll::Ready(None);
9820        }
9821        if this.is_terminated {
9822            panic!("polled VirtioVsockRequestStream after completion");
9823        }
9824        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9825            |bytes, handles| {
9826                match this.inner.channel().read_etc(cx, bytes, handles) {
9827                    std::task::Poll::Ready(Ok(())) => {}
9828                    std::task::Poll::Pending => return std::task::Poll::Pending,
9829                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9830                        this.is_terminated = true;
9831                        return std::task::Poll::Ready(None);
9832                    }
9833                    std::task::Poll::Ready(Err(e)) => {
9834                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9835                            e.into(),
9836                        ))))
9837                    }
9838                }
9839
9840                // A message has been received from the channel
9841                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9842
9843                std::task::Poll::Ready(Some(match header.ordinal {
9844                    0x72b44fb963480b11 => {
9845                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9846                        let mut req = fidl::new_empty!(
9847                            VirtioDeviceConfigureQueueRequest,
9848                            fidl::encoding::DefaultFuchsiaResourceDialect
9849                        );
9850                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
9851                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9852                        Ok(VirtioVsockRequest::ConfigureQueue {
9853                            queue: req.queue,
9854                            size: req.size,
9855                            desc: req.desc,
9856                            avail: req.avail,
9857                            used: req.used,
9858
9859                            responder: VirtioVsockConfigureQueueResponder {
9860                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9861                                tx_id: header.tx_id,
9862                            },
9863                        })
9864                    }
9865                    0x6e3a61d652499244 => {
9866                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9867                        let mut req = fidl::new_empty!(
9868                            VirtioDeviceNotifyQueueRequest,
9869                            fidl::encoding::DefaultFuchsiaResourceDialect
9870                        );
9871                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
9872                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9873                        Ok(VirtioVsockRequest::NotifyQueue { queue: req.queue, control_handle })
9874                    }
9875                    0x45707654f5d23c3f => {
9876                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9877                        let mut req = fidl::new_empty!(
9878                            VirtioDeviceReadyRequest,
9879                            fidl::encoding::DefaultFuchsiaResourceDialect
9880                        );
9881                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
9882                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9883                        Ok(VirtioVsockRequest::Ready {
9884                            negotiated_features: req.negotiated_features,
9885
9886                            responder: VirtioVsockReadyResponder {
9887                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9888                                tx_id: header.tx_id,
9889                            },
9890                        })
9891                    }
9892                    0x56433562cf67ae0f => {
9893                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9894                        let mut req = fidl::new_empty!(
9895                            VirtioVsockStartRequest,
9896                            fidl::encoding::DefaultFuchsiaResourceDialect
9897                        );
9898                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioVsockStartRequest>(&header, _body_bytes, handles, &mut req)?;
9899                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9900                        Ok(VirtioVsockRequest::Start {
9901                            start_info: req.start_info,
9902                            guest_cid: req.guest_cid,
9903                            listeners: req.listeners,
9904
9905                            responder: VirtioVsockStartResponder {
9906                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9907                                tx_id: header.tx_id,
9908                            },
9909                        })
9910                    }
9911                    _ => Err(fidl::Error::UnknownOrdinal {
9912                        ordinal: header.ordinal,
9913                        protocol_name:
9914                            <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9915                    }),
9916                }))
9917            },
9918        )
9919    }
9920}
9921
9922#[derive(Debug)]
9923pub enum VirtioVsockRequest {
9924    /// Configure a `queue` for the device. This specifies the `size` and the
9925    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
9926    ConfigureQueue {
9927        queue: u16,
9928        size: u16,
9929        desc: u64,
9930        avail: u64,
9931        used: u64,
9932        responder: VirtioVsockConfigureQueueResponder,
9933    },
9934    /// Notify a `queue` for the device. Primarily used for black-box testing.
9935    NotifyQueue { queue: u16, control_handle: VirtioVsockControlHandle },
9936    /// Ready a device. This provides the set of `negotiated_features` that the
9937    /// driver and device have agreed upon.
9938    Ready { negotiated_features: u32, responder: VirtioVsockReadyResponder },
9939    /// Start the vsock device, setting the guest_cid to the provided value.
9940    ///
9941    /// Returns:
9942    ///   - ZX_OK if device startup succeeded
9943    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
9944    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
9945    Start {
9946        start_info: StartInfo,
9947        guest_cid: u32,
9948        listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9949        responder: VirtioVsockStartResponder,
9950    },
9951}
9952
9953impl VirtioVsockRequest {
9954    #[allow(irrefutable_let_patterns)]
9955    pub fn into_configure_queue(
9956        self,
9957    ) -> Option<(u16, u16, u64, u64, u64, VirtioVsockConfigureQueueResponder)> {
9958        if let VirtioVsockRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
9959            self
9960        {
9961            Some((queue, size, desc, avail, used, responder))
9962        } else {
9963            None
9964        }
9965    }
9966
9967    #[allow(irrefutable_let_patterns)]
9968    pub fn into_notify_queue(self) -> Option<(u16, VirtioVsockControlHandle)> {
9969        if let VirtioVsockRequest::NotifyQueue { queue, control_handle } = self {
9970            Some((queue, control_handle))
9971        } else {
9972            None
9973        }
9974    }
9975
9976    #[allow(irrefutable_let_patterns)]
9977    pub fn into_ready(self) -> Option<(u32, VirtioVsockReadyResponder)> {
9978        if let VirtioVsockRequest::Ready { negotiated_features, responder } = self {
9979            Some((negotiated_features, responder))
9980        } else {
9981            None
9982        }
9983    }
9984
9985    #[allow(irrefutable_let_patterns)]
9986    pub fn into_start(
9987        self,
9988    ) -> Option<(
9989        StartInfo,
9990        u32,
9991        Vec<fidl_fuchsia_virtualization::Listener>,
9992        VirtioVsockStartResponder,
9993    )> {
9994        if let VirtioVsockRequest::Start { start_info, guest_cid, listeners, responder } = self {
9995            Some((start_info, guest_cid, listeners, responder))
9996        } else {
9997            None
9998        }
9999    }
10000
10001    /// Name of the method defined in FIDL
10002    pub fn method_name(&self) -> &'static str {
10003        match *self {
10004            VirtioVsockRequest::ConfigureQueue { .. } => "configure_queue",
10005            VirtioVsockRequest::NotifyQueue { .. } => "notify_queue",
10006            VirtioVsockRequest::Ready { .. } => "ready",
10007            VirtioVsockRequest::Start { .. } => "start",
10008        }
10009    }
10010}
10011
10012#[derive(Debug, Clone)]
10013pub struct VirtioVsockControlHandle {
10014    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10015}
10016
10017impl fidl::endpoints::ControlHandle for VirtioVsockControlHandle {
10018    fn shutdown(&self) {
10019        self.inner.shutdown()
10020    }
10021    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10022        self.inner.shutdown_with_epitaph(status)
10023    }
10024
10025    fn is_closed(&self) -> bool {
10026        self.inner.channel().is_closed()
10027    }
10028    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10029        self.inner.channel().on_closed()
10030    }
10031
10032    #[cfg(target_os = "fuchsia")]
10033    fn signal_peer(
10034        &self,
10035        clear_mask: zx::Signals,
10036        set_mask: zx::Signals,
10037    ) -> Result<(), zx_status::Status> {
10038        use fidl::Peered;
10039        self.inner.channel().signal_peer(clear_mask, set_mask)
10040    }
10041}
10042
10043impl VirtioVsockControlHandle {}
10044
10045#[must_use = "FIDL methods require a response to be sent"]
10046#[derive(Debug)]
10047pub struct VirtioVsockConfigureQueueResponder {
10048    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
10049    tx_id: u32,
10050}
10051
10052/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
10053/// if the responder is dropped without sending a response, so that the client
10054/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10055impl std::ops::Drop for VirtioVsockConfigureQueueResponder {
10056    fn drop(&mut self) {
10057        self.control_handle.shutdown();
10058        // Safety: drops once, never accessed again
10059        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10060    }
10061}
10062
10063impl fidl::endpoints::Responder for VirtioVsockConfigureQueueResponder {
10064    type ControlHandle = VirtioVsockControlHandle;
10065
10066    fn control_handle(&self) -> &VirtioVsockControlHandle {
10067        &self.control_handle
10068    }
10069
10070    fn drop_without_shutdown(mut self) {
10071        // Safety: drops once, never accessed again due to mem::forget
10072        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10073        // Prevent Drop from running (which would shut down the channel)
10074        std::mem::forget(self);
10075    }
10076}
10077
10078impl VirtioVsockConfigureQueueResponder {
10079    /// Sends a response to the FIDL transaction.
10080    ///
10081    /// Sets the channel to shutdown if an error occurs.
10082    pub fn send(self) -> Result<(), fidl::Error> {
10083        let _result = self.send_raw();
10084        if _result.is_err() {
10085            self.control_handle.shutdown();
10086        }
10087        self.drop_without_shutdown();
10088        _result
10089    }
10090
10091    /// Similar to "send" but does not shutdown the channel if an error occurs.
10092    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10093        let _result = self.send_raw();
10094        self.drop_without_shutdown();
10095        _result
10096    }
10097
10098    fn send_raw(&self) -> Result<(), fidl::Error> {
10099        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10100            (),
10101            self.tx_id,
10102            0x72b44fb963480b11,
10103            fidl::encoding::DynamicFlags::empty(),
10104        )
10105    }
10106}
10107
10108#[must_use = "FIDL methods require a response to be sent"]
10109#[derive(Debug)]
10110pub struct VirtioVsockReadyResponder {
10111    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
10112    tx_id: u32,
10113}
10114
10115/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
10116/// if the responder is dropped without sending a response, so that the client
10117/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10118impl std::ops::Drop for VirtioVsockReadyResponder {
10119    fn drop(&mut self) {
10120        self.control_handle.shutdown();
10121        // Safety: drops once, never accessed again
10122        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10123    }
10124}
10125
10126impl fidl::endpoints::Responder for VirtioVsockReadyResponder {
10127    type ControlHandle = VirtioVsockControlHandle;
10128
10129    fn control_handle(&self) -> &VirtioVsockControlHandle {
10130        &self.control_handle
10131    }
10132
10133    fn drop_without_shutdown(mut self) {
10134        // Safety: drops once, never accessed again due to mem::forget
10135        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10136        // Prevent Drop from running (which would shut down the channel)
10137        std::mem::forget(self);
10138    }
10139}
10140
10141impl VirtioVsockReadyResponder {
10142    /// Sends a response to the FIDL transaction.
10143    ///
10144    /// Sets the channel to shutdown if an error occurs.
10145    pub fn send(self) -> Result<(), fidl::Error> {
10146        let _result = self.send_raw();
10147        if _result.is_err() {
10148            self.control_handle.shutdown();
10149        }
10150        self.drop_without_shutdown();
10151        _result
10152    }
10153
10154    /// Similar to "send" but does not shutdown the channel if an error occurs.
10155    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10156        let _result = self.send_raw();
10157        self.drop_without_shutdown();
10158        _result
10159    }
10160
10161    fn send_raw(&self) -> Result<(), fidl::Error> {
10162        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10163            (),
10164            self.tx_id,
10165            0x45707654f5d23c3f,
10166            fidl::encoding::DynamicFlags::empty(),
10167        )
10168    }
10169}
10170
10171#[must_use = "FIDL methods require a response to be sent"]
10172#[derive(Debug)]
10173pub struct VirtioVsockStartResponder {
10174    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
10175    tx_id: u32,
10176}
10177
10178/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
10179/// if the responder is dropped without sending a response, so that the client
10180/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10181impl std::ops::Drop for VirtioVsockStartResponder {
10182    fn drop(&mut self) {
10183        self.control_handle.shutdown();
10184        // Safety: drops once, never accessed again
10185        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10186    }
10187}
10188
10189impl fidl::endpoints::Responder for VirtioVsockStartResponder {
10190    type ControlHandle = VirtioVsockControlHandle;
10191
10192    fn control_handle(&self) -> &VirtioVsockControlHandle {
10193        &self.control_handle
10194    }
10195
10196    fn drop_without_shutdown(mut self) {
10197        // Safety: drops once, never accessed again due to mem::forget
10198        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10199        // Prevent Drop from running (which would shut down the channel)
10200        std::mem::forget(self);
10201    }
10202}
10203
10204impl VirtioVsockStartResponder {
10205    /// Sends a response to the FIDL transaction.
10206    ///
10207    /// Sets the channel to shutdown if an error occurs.
10208    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
10209        let _result = self.send_raw(result);
10210        if _result.is_err() {
10211            self.control_handle.shutdown();
10212        }
10213        self.drop_without_shutdown();
10214        _result
10215    }
10216
10217    /// Similar to "send" but does not shutdown the channel if an error occurs.
10218    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
10219        let _result = self.send_raw(result);
10220        self.drop_without_shutdown();
10221        _result
10222    }
10223
10224    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
10225        self.control_handle
10226            .inner
10227            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
10228                result,
10229                self.tx_id,
10230                0x56433562cf67ae0f,
10231                fidl::encoding::DynamicFlags::empty(),
10232            )
10233    }
10234}
10235
10236#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10237pub struct VirtioWaylandMarker;
10238
10239impl fidl::endpoints::ProtocolMarker for VirtioWaylandMarker {
10240    type Proxy = VirtioWaylandProxy;
10241    type RequestStream = VirtioWaylandRequestStream;
10242    #[cfg(target_os = "fuchsia")]
10243    type SynchronousProxy = VirtioWaylandSynchronousProxy;
10244
10245    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioWayland";
10246}
10247impl fidl::endpoints::DiscoverableProtocolMarker for VirtioWaylandMarker {}
10248
10249pub trait VirtioWaylandProxyInterface: Send + Sync {
10250    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10251    fn r#configure_queue(
10252        &self,
10253        queue: u16,
10254        size: u16,
10255        desc: u64,
10256        avail: u64,
10257        used: u64,
10258    ) -> Self::ConfigureQueueResponseFut;
10259    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
10260    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10261    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
10262    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10263    fn r#start(
10264        &self,
10265        start_info: StartInfo,
10266        vmar: fidl::Vmar,
10267        sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10268        scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
10269    ) -> Self::StartResponseFut;
10270    type StartWithWaylandServer_ResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10271        + Send;
10272    fn r#start_with_wayland_server_(
10273        &self,
10274        start_info: StartInfo,
10275        vmar: fidl::Vmar,
10276        wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10277        sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10278        scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
10279    ) -> Self::StartWithWaylandServer_ResponseFut;
10280    fn r#get_importer(
10281        &self,
10282        importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10283    ) -> Result<(), fidl::Error>;
10284}
10285#[derive(Debug)]
10286#[cfg(target_os = "fuchsia")]
10287pub struct VirtioWaylandSynchronousProxy {
10288    client: fidl::client::sync::Client,
10289}
10290
10291#[cfg(target_os = "fuchsia")]
10292impl fidl::endpoints::SynchronousProxy for VirtioWaylandSynchronousProxy {
10293    type Proxy = VirtioWaylandProxy;
10294    type Protocol = VirtioWaylandMarker;
10295
10296    fn from_channel(inner: fidl::Channel) -> Self {
10297        Self::new(inner)
10298    }
10299
10300    fn into_channel(self) -> fidl::Channel {
10301        self.client.into_channel()
10302    }
10303
10304    fn as_channel(&self) -> &fidl::Channel {
10305        self.client.as_channel()
10306    }
10307}
10308
10309#[cfg(target_os = "fuchsia")]
10310impl VirtioWaylandSynchronousProxy {
10311    pub fn new(channel: fidl::Channel) -> Self {
10312        let protocol_name = <VirtioWaylandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10313        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10314    }
10315
10316    pub fn into_channel(self) -> fidl::Channel {
10317        self.client.into_channel()
10318    }
10319
10320    /// Waits until an event arrives and returns it. It is safe for other
10321    /// threads to make concurrent requests while waiting for an event.
10322    pub fn wait_for_event(
10323        &self,
10324        deadline: zx::MonotonicInstant,
10325    ) -> Result<VirtioWaylandEvent, fidl::Error> {
10326        VirtioWaylandEvent::decode(self.client.wait_for_event(deadline)?)
10327    }
10328
10329    /// Configure a `queue` for the device. This specifies the `size` and the
10330    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
10331    pub fn r#configure_queue(
10332        &self,
10333        mut queue: u16,
10334        mut size: u16,
10335        mut desc: u64,
10336        mut avail: u64,
10337        mut used: u64,
10338        ___deadline: zx::MonotonicInstant,
10339    ) -> Result<(), fidl::Error> {
10340        let _response = self
10341            .client
10342            .send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
10343                (queue, size, desc, avail, used),
10344                0x72b44fb963480b11,
10345                fidl::encoding::DynamicFlags::empty(),
10346                ___deadline,
10347            )?;
10348        Ok(_response)
10349    }
10350
10351    /// Notify a `queue` for the device. Primarily used for black-box testing.
10352    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
10353        self.client.send::<VirtioDeviceNotifyQueueRequest>(
10354            (queue,),
10355            0x6e3a61d652499244,
10356            fidl::encoding::DynamicFlags::empty(),
10357        )
10358    }
10359
10360    /// Ready a device. This provides the set of `negotiated_features` that the
10361    /// driver and device have agreed upon.
10362    pub fn r#ready(
10363        &self,
10364        mut negotiated_features: u32,
10365        ___deadline: zx::MonotonicInstant,
10366    ) -> Result<(), fidl::Error> {
10367        let _response =
10368            self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
10369                (negotiated_features,),
10370                0x45707654f5d23c3f,
10371                fidl::encoding::DynamicFlags::empty(),
10372                ___deadline,
10373            )?;
10374        Ok(_response)
10375    }
10376
10377    /// Start the wayland device using the built-in wayland server.
10378    pub fn r#start(
10379        &self,
10380        mut start_info: StartInfo,
10381        mut vmar: fidl::Vmar,
10382        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10383        mut scenic_allocator: fidl::endpoints::ClientEnd<
10384            fidl_fuchsia_ui_composition::AllocatorMarker,
10385        >,
10386        ___deadline: zx::MonotonicInstant,
10387    ) -> Result<(), fidl::Error> {
10388        let _response =
10389            self.client.send_query::<VirtioWaylandStartRequest, fidl::encoding::EmptyPayload>(
10390                (&mut start_info, vmar, sysmem_allocator, scenic_allocator),
10391                0x1f60e084e30deee6,
10392                fidl::encoding::DynamicFlags::empty(),
10393                ___deadline,
10394            )?;
10395        Ok(_response)
10396    }
10397
10398    /// Start the wayland device using the provided wayland server.
10399    pub fn r#start_with_wayland_server_(
10400        &self,
10401        mut start_info: StartInfo,
10402        mut vmar: fidl::Vmar,
10403        mut wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10404        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10405        mut scenic_allocator: fidl::endpoints::ClientEnd<
10406            fidl_fuchsia_ui_composition::AllocatorMarker,
10407        >,
10408        ___deadline: zx::MonotonicInstant,
10409    ) -> Result<(), fidl::Error> {
10410        let _response = self
10411            .client
10412            .send_query::<VirtioWaylandStartWithWaylandServerRequest, fidl::encoding::EmptyPayload>(
10413                (&mut start_info, vmar, wayland_server, sysmem_allocator, scenic_allocator),
10414                0x3f2e38dfb60077e9,
10415                fidl::encoding::DynamicFlags::empty(),
10416                ___deadline,
10417            )?;
10418        Ok(_response)
10419    }
10420
10421    pub fn r#get_importer(
10422        &self,
10423        mut importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10424    ) -> Result<(), fidl::Error> {
10425        self.client.send::<VirtioWaylandGetImporterRequest>(
10426            (importer,),
10427            0x49d1b3c94767a541,
10428            fidl::encoding::DynamicFlags::empty(),
10429        )
10430    }
10431}
10432
10433#[cfg(target_os = "fuchsia")]
10434impl From<VirtioWaylandSynchronousProxy> for zx::Handle {
10435    fn from(value: VirtioWaylandSynchronousProxy) -> Self {
10436        value.into_channel().into()
10437    }
10438}
10439
10440#[cfg(target_os = "fuchsia")]
10441impl From<fidl::Channel> for VirtioWaylandSynchronousProxy {
10442    fn from(value: fidl::Channel) -> Self {
10443        Self::new(value)
10444    }
10445}
10446
10447#[derive(Debug, Clone)]
10448pub struct VirtioWaylandProxy {
10449    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10450}
10451
10452impl fidl::endpoints::Proxy for VirtioWaylandProxy {
10453    type Protocol = VirtioWaylandMarker;
10454
10455    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10456        Self::new(inner)
10457    }
10458
10459    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10460        self.client.into_channel().map_err(|client| Self { client })
10461    }
10462
10463    fn as_channel(&self) -> &::fidl::AsyncChannel {
10464        self.client.as_channel()
10465    }
10466}
10467
10468impl VirtioWaylandProxy {
10469    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioWayland.
10470    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10471        let protocol_name = <VirtioWaylandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10472        Self { client: fidl::client::Client::new(channel, protocol_name) }
10473    }
10474
10475    /// Get a Stream of events from the remote end of the protocol.
10476    ///
10477    /// # Panics
10478    ///
10479    /// Panics if the event stream was already taken.
10480    pub fn take_event_stream(&self) -> VirtioWaylandEventStream {
10481        VirtioWaylandEventStream { event_receiver: self.client.take_event_receiver() }
10482    }
10483
10484    /// Configure a `queue` for the device. This specifies the `size` and the
10485    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
10486    pub fn r#configure_queue(
10487        &self,
10488        mut queue: u16,
10489        mut size: u16,
10490        mut desc: u64,
10491        mut avail: u64,
10492        mut used: u64,
10493    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10494        VirtioWaylandProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
10495    }
10496
10497    /// Notify a `queue` for the device. Primarily used for black-box testing.
10498    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
10499        VirtioWaylandProxyInterface::r#notify_queue(self, queue)
10500    }
10501
10502    /// Ready a device. This provides the set of `negotiated_features` that the
10503    /// driver and device have agreed upon.
10504    pub fn r#ready(
10505        &self,
10506        mut negotiated_features: u32,
10507    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10508        VirtioWaylandProxyInterface::r#ready(self, negotiated_features)
10509    }
10510
10511    /// Start the wayland device using the built-in wayland server.
10512    pub fn r#start(
10513        &self,
10514        mut start_info: StartInfo,
10515        mut vmar: fidl::Vmar,
10516        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10517        mut scenic_allocator: fidl::endpoints::ClientEnd<
10518            fidl_fuchsia_ui_composition::AllocatorMarker,
10519        >,
10520    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10521        VirtioWaylandProxyInterface::r#start(
10522            self,
10523            start_info,
10524            vmar,
10525            sysmem_allocator,
10526            scenic_allocator,
10527        )
10528    }
10529
10530    /// Start the wayland device using the provided wayland server.
10531    pub fn r#start_with_wayland_server_(
10532        &self,
10533        mut start_info: StartInfo,
10534        mut vmar: fidl::Vmar,
10535        mut wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10536        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10537        mut scenic_allocator: fidl::endpoints::ClientEnd<
10538            fidl_fuchsia_ui_composition::AllocatorMarker,
10539        >,
10540    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10541        VirtioWaylandProxyInterface::r#start_with_wayland_server_(
10542            self,
10543            start_info,
10544            vmar,
10545            wayland_server,
10546            sysmem_allocator,
10547            scenic_allocator,
10548        )
10549    }
10550
10551    pub fn r#get_importer(
10552        &self,
10553        mut importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10554    ) -> Result<(), fidl::Error> {
10555        VirtioWaylandProxyInterface::r#get_importer(self, importer)
10556    }
10557}
10558
10559impl VirtioWaylandProxyInterface for VirtioWaylandProxy {
10560    type ConfigureQueueResponseFut =
10561        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10562    fn r#configure_queue(
10563        &self,
10564        mut queue: u16,
10565        mut size: u16,
10566        mut desc: u64,
10567        mut avail: u64,
10568        mut used: u64,
10569    ) -> Self::ConfigureQueueResponseFut {
10570        fn _decode(
10571            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10572        ) -> Result<(), fidl::Error> {
10573            let _response = fidl::client::decode_transaction_body::<
10574                fidl::encoding::EmptyPayload,
10575                fidl::encoding::DefaultFuchsiaResourceDialect,
10576                0x72b44fb963480b11,
10577            >(_buf?)?;
10578            Ok(_response)
10579        }
10580        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
10581            (queue, size, desc, avail, used),
10582            0x72b44fb963480b11,
10583            fidl::encoding::DynamicFlags::empty(),
10584            _decode,
10585        )
10586    }
10587
10588    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
10589        self.client.send::<VirtioDeviceNotifyQueueRequest>(
10590            (queue,),
10591            0x6e3a61d652499244,
10592            fidl::encoding::DynamicFlags::empty(),
10593        )
10594    }
10595
10596    type ReadyResponseFut =
10597        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10598    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
10599        fn _decode(
10600            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10601        ) -> Result<(), fidl::Error> {
10602            let _response = fidl::client::decode_transaction_body::<
10603                fidl::encoding::EmptyPayload,
10604                fidl::encoding::DefaultFuchsiaResourceDialect,
10605                0x45707654f5d23c3f,
10606            >(_buf?)?;
10607            Ok(_response)
10608        }
10609        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
10610            (negotiated_features,),
10611            0x45707654f5d23c3f,
10612            fidl::encoding::DynamicFlags::empty(),
10613            _decode,
10614        )
10615    }
10616
10617    type StartResponseFut =
10618        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10619    fn r#start(
10620        &self,
10621        mut start_info: StartInfo,
10622        mut vmar: fidl::Vmar,
10623        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10624        mut scenic_allocator: fidl::endpoints::ClientEnd<
10625            fidl_fuchsia_ui_composition::AllocatorMarker,
10626        >,
10627    ) -> Self::StartResponseFut {
10628        fn _decode(
10629            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10630        ) -> Result<(), fidl::Error> {
10631            let _response = fidl::client::decode_transaction_body::<
10632                fidl::encoding::EmptyPayload,
10633                fidl::encoding::DefaultFuchsiaResourceDialect,
10634                0x1f60e084e30deee6,
10635            >(_buf?)?;
10636            Ok(_response)
10637        }
10638        self.client.send_query_and_decode::<VirtioWaylandStartRequest, ()>(
10639            (&mut start_info, vmar, sysmem_allocator, scenic_allocator),
10640            0x1f60e084e30deee6,
10641            fidl::encoding::DynamicFlags::empty(),
10642            _decode,
10643        )
10644    }
10645
10646    type StartWithWaylandServer_ResponseFut =
10647        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10648    fn r#start_with_wayland_server_(
10649        &self,
10650        mut start_info: StartInfo,
10651        mut vmar: fidl::Vmar,
10652        mut wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10653        mut sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10654        mut scenic_allocator: fidl::endpoints::ClientEnd<
10655            fidl_fuchsia_ui_composition::AllocatorMarker,
10656        >,
10657    ) -> Self::StartWithWaylandServer_ResponseFut {
10658        fn _decode(
10659            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10660        ) -> Result<(), fidl::Error> {
10661            let _response = fidl::client::decode_transaction_body::<
10662                fidl::encoding::EmptyPayload,
10663                fidl::encoding::DefaultFuchsiaResourceDialect,
10664                0x3f2e38dfb60077e9,
10665            >(_buf?)?;
10666            Ok(_response)
10667        }
10668        self.client.send_query_and_decode::<VirtioWaylandStartWithWaylandServerRequest, ()>(
10669            (&mut start_info, vmar, wayland_server, sysmem_allocator, scenic_allocator),
10670            0x3f2e38dfb60077e9,
10671            fidl::encoding::DynamicFlags::empty(),
10672            _decode,
10673        )
10674    }
10675
10676    fn r#get_importer(
10677        &self,
10678        mut importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10679    ) -> Result<(), fidl::Error> {
10680        self.client.send::<VirtioWaylandGetImporterRequest>(
10681            (importer,),
10682            0x49d1b3c94767a541,
10683            fidl::encoding::DynamicFlags::empty(),
10684        )
10685    }
10686}
10687
10688pub struct VirtioWaylandEventStream {
10689    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
10690}
10691
10692impl std::marker::Unpin for VirtioWaylandEventStream {}
10693
10694impl futures::stream::FusedStream for VirtioWaylandEventStream {
10695    fn is_terminated(&self) -> bool {
10696        self.event_receiver.is_terminated()
10697    }
10698}
10699
10700impl futures::Stream for VirtioWaylandEventStream {
10701    type Item = Result<VirtioWaylandEvent, fidl::Error>;
10702
10703    fn poll_next(
10704        mut self: std::pin::Pin<&mut Self>,
10705        cx: &mut std::task::Context<'_>,
10706    ) -> std::task::Poll<Option<Self::Item>> {
10707        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10708            &mut self.event_receiver,
10709            cx
10710        )?) {
10711            Some(buf) => std::task::Poll::Ready(Some(VirtioWaylandEvent::decode(buf))),
10712            None => std::task::Poll::Ready(None),
10713        }
10714    }
10715}
10716
10717#[derive(Debug)]
10718pub enum VirtioWaylandEvent {}
10719
10720impl VirtioWaylandEvent {
10721    /// Decodes a message buffer as a [`VirtioWaylandEvent`].
10722    fn decode(
10723        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10724    ) -> Result<VirtioWaylandEvent, fidl::Error> {
10725        let (bytes, _handles) = buf.split_mut();
10726        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10727        debug_assert_eq!(tx_header.tx_id, 0);
10728        match tx_header.ordinal {
10729            _ => Err(fidl::Error::UnknownOrdinal {
10730                ordinal: tx_header.ordinal,
10731                protocol_name: <VirtioWaylandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10732            }),
10733        }
10734    }
10735}
10736
10737/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioWayland.
10738pub struct VirtioWaylandRequestStream {
10739    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10740    is_terminated: bool,
10741}
10742
10743impl std::marker::Unpin for VirtioWaylandRequestStream {}
10744
10745impl futures::stream::FusedStream for VirtioWaylandRequestStream {
10746    fn is_terminated(&self) -> bool {
10747        self.is_terminated
10748    }
10749}
10750
10751impl fidl::endpoints::RequestStream for VirtioWaylandRequestStream {
10752    type Protocol = VirtioWaylandMarker;
10753    type ControlHandle = VirtioWaylandControlHandle;
10754
10755    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
10756        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10757    }
10758
10759    fn control_handle(&self) -> Self::ControlHandle {
10760        VirtioWaylandControlHandle { inner: self.inner.clone() }
10761    }
10762
10763    fn into_inner(
10764        self,
10765    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
10766    {
10767        (self.inner, self.is_terminated)
10768    }
10769
10770    fn from_inner(
10771        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10772        is_terminated: bool,
10773    ) -> Self {
10774        Self { inner, is_terminated }
10775    }
10776}
10777
10778impl futures::Stream for VirtioWaylandRequestStream {
10779    type Item = Result<VirtioWaylandRequest, fidl::Error>;
10780
10781    fn poll_next(
10782        mut self: std::pin::Pin<&mut Self>,
10783        cx: &mut std::task::Context<'_>,
10784    ) -> std::task::Poll<Option<Self::Item>> {
10785        let this = &mut *self;
10786        if this.inner.check_shutdown(cx) {
10787            this.is_terminated = true;
10788            return std::task::Poll::Ready(None);
10789        }
10790        if this.is_terminated {
10791            panic!("polled VirtioWaylandRequestStream after completion");
10792        }
10793        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
10794            |bytes, handles| {
10795                match this.inner.channel().read_etc(cx, bytes, handles) {
10796                    std::task::Poll::Ready(Ok(())) => {}
10797                    std::task::Poll::Pending => return std::task::Poll::Pending,
10798                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
10799                        this.is_terminated = true;
10800                        return std::task::Poll::Ready(None);
10801                    }
10802                    std::task::Poll::Ready(Err(e)) => {
10803                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10804                            e.into(),
10805                        ))))
10806                    }
10807                }
10808
10809                // A message has been received from the channel
10810                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10811
10812                std::task::Poll::Ready(Some(match header.ordinal {
10813                    0x72b44fb963480b11 => {
10814                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10815                        let mut req = fidl::new_empty!(
10816                            VirtioDeviceConfigureQueueRequest,
10817                            fidl::encoding::DefaultFuchsiaResourceDialect
10818                        );
10819                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
10820                        let control_handle =
10821                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10822                        Ok(VirtioWaylandRequest::ConfigureQueue {
10823                            queue: req.queue,
10824                            size: req.size,
10825                            desc: req.desc,
10826                            avail: req.avail,
10827                            used: req.used,
10828
10829                            responder: VirtioWaylandConfigureQueueResponder {
10830                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10831                                tx_id: header.tx_id,
10832                            },
10833                        })
10834                    }
10835                    0x6e3a61d652499244 => {
10836                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10837                        let mut req = fidl::new_empty!(
10838                            VirtioDeviceNotifyQueueRequest,
10839                            fidl::encoding::DefaultFuchsiaResourceDialect
10840                        );
10841                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
10842                        let control_handle =
10843                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10844                        Ok(VirtioWaylandRequest::NotifyQueue { queue: req.queue, control_handle })
10845                    }
10846                    0x45707654f5d23c3f => {
10847                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10848                        let mut req = fidl::new_empty!(
10849                            VirtioDeviceReadyRequest,
10850                            fidl::encoding::DefaultFuchsiaResourceDialect
10851                        );
10852                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
10853                        let control_handle =
10854                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10855                        Ok(VirtioWaylandRequest::Ready {
10856                            negotiated_features: req.negotiated_features,
10857
10858                            responder: VirtioWaylandReadyResponder {
10859                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10860                                tx_id: header.tx_id,
10861                            },
10862                        })
10863                    }
10864                    0x1f60e084e30deee6 => {
10865                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10866                        let mut req = fidl::new_empty!(
10867                            VirtioWaylandStartRequest,
10868                            fidl::encoding::DefaultFuchsiaResourceDialect
10869                        );
10870                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandStartRequest>(&header, _body_bytes, handles, &mut req)?;
10871                        let control_handle =
10872                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10873                        Ok(VirtioWaylandRequest::Start {
10874                            start_info: req.start_info,
10875                            vmar: req.vmar,
10876                            sysmem_allocator: req.sysmem_allocator,
10877                            scenic_allocator: req.scenic_allocator,
10878
10879                            responder: VirtioWaylandStartResponder {
10880                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10881                                tx_id: header.tx_id,
10882                            },
10883                        })
10884                    }
10885                    0x3f2e38dfb60077e9 => {
10886                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10887                        let mut req = fidl::new_empty!(
10888                            VirtioWaylandStartWithWaylandServerRequest,
10889                            fidl::encoding::DefaultFuchsiaResourceDialect
10890                        );
10891                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandStartWithWaylandServerRequest>(&header, _body_bytes, handles, &mut req)?;
10892                        let control_handle =
10893                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10894                        Ok(VirtioWaylandRequest::StartWithWaylandServer_ {
10895                            start_info: req.start_info,
10896                            vmar: req.vmar,
10897                            wayland_server: req.wayland_server,
10898                            sysmem_allocator: req.sysmem_allocator,
10899                            scenic_allocator: req.scenic_allocator,
10900
10901                            responder: VirtioWaylandStartWithWaylandServer_Responder {
10902                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10903                                tx_id: header.tx_id,
10904                            },
10905                        })
10906                    }
10907                    0x49d1b3c94767a541 => {
10908                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10909                        let mut req = fidl::new_empty!(
10910                            VirtioWaylandGetImporterRequest,
10911                            fidl::encoding::DefaultFuchsiaResourceDialect
10912                        );
10913                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandGetImporterRequest>(&header, _body_bytes, handles, &mut req)?;
10914                        let control_handle =
10915                            VirtioWaylandControlHandle { inner: this.inner.clone() };
10916                        Ok(VirtioWaylandRequest::GetImporter {
10917                            importer: req.importer,
10918
10919                            control_handle,
10920                        })
10921                    }
10922                    _ => Err(fidl::Error::UnknownOrdinal {
10923                        ordinal: header.ordinal,
10924                        protocol_name:
10925                            <VirtioWaylandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10926                    }),
10927                }))
10928            },
10929        )
10930    }
10931}
10932
10933#[derive(Debug)]
10934pub enum VirtioWaylandRequest {
10935    /// Configure a `queue` for the device. This specifies the `size` and the
10936    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
10937    ConfigureQueue {
10938        queue: u16,
10939        size: u16,
10940        desc: u64,
10941        avail: u64,
10942        used: u64,
10943        responder: VirtioWaylandConfigureQueueResponder,
10944    },
10945    /// Notify a `queue` for the device. Primarily used for black-box testing.
10946    NotifyQueue { queue: u16, control_handle: VirtioWaylandControlHandle },
10947    /// Ready a device. This provides the set of `negotiated_features` that the
10948    /// driver and device have agreed upon.
10949    Ready { negotiated_features: u32, responder: VirtioWaylandReadyResponder },
10950    /// Start the wayland device using the built-in wayland server.
10951    Start {
10952        start_info: StartInfo,
10953        vmar: fidl::Vmar,
10954        sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10955        scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
10956        responder: VirtioWaylandStartResponder,
10957    },
10958    /// Start the wayland device using the provided wayland server.
10959    StartWithWaylandServer_ {
10960        start_info: StartInfo,
10961        vmar: fidl::Vmar,
10962        wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
10963        sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
10964        scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
10965        responder: VirtioWaylandStartWithWaylandServer_Responder,
10966    },
10967    GetImporter {
10968        importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
10969        control_handle: VirtioWaylandControlHandle,
10970    },
10971}
10972
10973impl VirtioWaylandRequest {
10974    #[allow(irrefutable_let_patterns)]
10975    pub fn into_configure_queue(
10976        self,
10977    ) -> Option<(u16, u16, u64, u64, u64, VirtioWaylandConfigureQueueResponder)> {
10978        if let VirtioWaylandRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
10979            self
10980        {
10981            Some((queue, size, desc, avail, used, responder))
10982        } else {
10983            None
10984        }
10985    }
10986
10987    #[allow(irrefutable_let_patterns)]
10988    pub fn into_notify_queue(self) -> Option<(u16, VirtioWaylandControlHandle)> {
10989        if let VirtioWaylandRequest::NotifyQueue { queue, control_handle } = self {
10990            Some((queue, control_handle))
10991        } else {
10992            None
10993        }
10994    }
10995
10996    #[allow(irrefutable_let_patterns)]
10997    pub fn into_ready(self) -> Option<(u32, VirtioWaylandReadyResponder)> {
10998        if let VirtioWaylandRequest::Ready { negotiated_features, responder } = self {
10999            Some((negotiated_features, responder))
11000        } else {
11001            None
11002        }
11003    }
11004
11005    #[allow(irrefutable_let_patterns)]
11006    pub fn into_start(
11007        self,
11008    ) -> Option<(
11009        StartInfo,
11010        fidl::Vmar,
11011        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
11012        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
11013        VirtioWaylandStartResponder,
11014    )> {
11015        if let VirtioWaylandRequest::Start {
11016            start_info,
11017            vmar,
11018            sysmem_allocator,
11019            scenic_allocator,
11020            responder,
11021        } = self
11022        {
11023            Some((start_info, vmar, sysmem_allocator, scenic_allocator, responder))
11024        } else {
11025            None
11026        }
11027    }
11028
11029    #[allow(irrefutable_let_patterns)]
11030    pub fn into_start_with_wayland_server_(
11031        self,
11032    ) -> Option<(
11033        StartInfo,
11034        fidl::Vmar,
11035        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
11036        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
11037        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
11038        VirtioWaylandStartWithWaylandServer_Responder,
11039    )> {
11040        if let VirtioWaylandRequest::StartWithWaylandServer_ {
11041            start_info,
11042            vmar,
11043            wayland_server,
11044            sysmem_allocator,
11045            scenic_allocator,
11046            responder,
11047        } = self
11048        {
11049            Some((start_info, vmar, wayland_server, sysmem_allocator, scenic_allocator, responder))
11050        } else {
11051            None
11052        }
11053    }
11054
11055    #[allow(irrefutable_let_patterns)]
11056    pub fn into_get_importer(
11057        self,
11058    ) -> Option<(fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>, VirtioWaylandControlHandle)>
11059    {
11060        if let VirtioWaylandRequest::GetImporter { importer, control_handle } = self {
11061            Some((importer, control_handle))
11062        } else {
11063            None
11064        }
11065    }
11066
11067    /// Name of the method defined in FIDL
11068    pub fn method_name(&self) -> &'static str {
11069        match *self {
11070            VirtioWaylandRequest::ConfigureQueue { .. } => "configure_queue",
11071            VirtioWaylandRequest::NotifyQueue { .. } => "notify_queue",
11072            VirtioWaylandRequest::Ready { .. } => "ready",
11073            VirtioWaylandRequest::Start { .. } => "start",
11074            VirtioWaylandRequest::StartWithWaylandServer_ { .. } => "start_with_wayland_server_",
11075            VirtioWaylandRequest::GetImporter { .. } => "get_importer",
11076        }
11077    }
11078}
11079
11080#[derive(Debug, Clone)]
11081pub struct VirtioWaylandControlHandle {
11082    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11083}
11084
11085impl fidl::endpoints::ControlHandle for VirtioWaylandControlHandle {
11086    fn shutdown(&self) {
11087        self.inner.shutdown()
11088    }
11089    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11090        self.inner.shutdown_with_epitaph(status)
11091    }
11092
11093    fn is_closed(&self) -> bool {
11094        self.inner.channel().is_closed()
11095    }
11096    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11097        self.inner.channel().on_closed()
11098    }
11099
11100    #[cfg(target_os = "fuchsia")]
11101    fn signal_peer(
11102        &self,
11103        clear_mask: zx::Signals,
11104        set_mask: zx::Signals,
11105    ) -> Result<(), zx_status::Status> {
11106        use fidl::Peered;
11107        self.inner.channel().signal_peer(clear_mask, set_mask)
11108    }
11109}
11110
11111impl VirtioWaylandControlHandle {}
11112
11113#[must_use = "FIDL methods require a response to be sent"]
11114#[derive(Debug)]
11115pub struct VirtioWaylandConfigureQueueResponder {
11116    control_handle: std::mem::ManuallyDrop<VirtioWaylandControlHandle>,
11117    tx_id: u32,
11118}
11119
11120/// Set the the channel to be shutdown (see [`VirtioWaylandControlHandle::shutdown`])
11121/// if the responder is dropped without sending a response, so that the client
11122/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11123impl std::ops::Drop for VirtioWaylandConfigureQueueResponder {
11124    fn drop(&mut self) {
11125        self.control_handle.shutdown();
11126        // Safety: drops once, never accessed again
11127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11128    }
11129}
11130
11131impl fidl::endpoints::Responder for VirtioWaylandConfigureQueueResponder {
11132    type ControlHandle = VirtioWaylandControlHandle;
11133
11134    fn control_handle(&self) -> &VirtioWaylandControlHandle {
11135        &self.control_handle
11136    }
11137
11138    fn drop_without_shutdown(mut self) {
11139        // Safety: drops once, never accessed again due to mem::forget
11140        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11141        // Prevent Drop from running (which would shut down the channel)
11142        std::mem::forget(self);
11143    }
11144}
11145
11146impl VirtioWaylandConfigureQueueResponder {
11147    /// Sends a response to the FIDL transaction.
11148    ///
11149    /// Sets the channel to shutdown if an error occurs.
11150    pub fn send(self) -> Result<(), fidl::Error> {
11151        let _result = self.send_raw();
11152        if _result.is_err() {
11153            self.control_handle.shutdown();
11154        }
11155        self.drop_without_shutdown();
11156        _result
11157    }
11158
11159    /// Similar to "send" but does not shutdown the channel if an error occurs.
11160    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11161        let _result = self.send_raw();
11162        self.drop_without_shutdown();
11163        _result
11164    }
11165
11166    fn send_raw(&self) -> Result<(), fidl::Error> {
11167        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11168            (),
11169            self.tx_id,
11170            0x72b44fb963480b11,
11171            fidl::encoding::DynamicFlags::empty(),
11172        )
11173    }
11174}
11175
11176#[must_use = "FIDL methods require a response to be sent"]
11177#[derive(Debug)]
11178pub struct VirtioWaylandReadyResponder {
11179    control_handle: std::mem::ManuallyDrop<VirtioWaylandControlHandle>,
11180    tx_id: u32,
11181}
11182
11183/// Set the the channel to be shutdown (see [`VirtioWaylandControlHandle::shutdown`])
11184/// if the responder is dropped without sending a response, so that the client
11185/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11186impl std::ops::Drop for VirtioWaylandReadyResponder {
11187    fn drop(&mut self) {
11188        self.control_handle.shutdown();
11189        // Safety: drops once, never accessed again
11190        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11191    }
11192}
11193
11194impl fidl::endpoints::Responder for VirtioWaylandReadyResponder {
11195    type ControlHandle = VirtioWaylandControlHandle;
11196
11197    fn control_handle(&self) -> &VirtioWaylandControlHandle {
11198        &self.control_handle
11199    }
11200
11201    fn drop_without_shutdown(mut self) {
11202        // Safety: drops once, never accessed again due to mem::forget
11203        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11204        // Prevent Drop from running (which would shut down the channel)
11205        std::mem::forget(self);
11206    }
11207}
11208
11209impl VirtioWaylandReadyResponder {
11210    /// Sends a response to the FIDL transaction.
11211    ///
11212    /// Sets the channel to shutdown if an error occurs.
11213    pub fn send(self) -> Result<(), fidl::Error> {
11214        let _result = self.send_raw();
11215        if _result.is_err() {
11216            self.control_handle.shutdown();
11217        }
11218        self.drop_without_shutdown();
11219        _result
11220    }
11221
11222    /// Similar to "send" but does not shutdown the channel if an error occurs.
11223    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11224        let _result = self.send_raw();
11225        self.drop_without_shutdown();
11226        _result
11227    }
11228
11229    fn send_raw(&self) -> Result<(), fidl::Error> {
11230        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11231            (),
11232            self.tx_id,
11233            0x45707654f5d23c3f,
11234            fidl::encoding::DynamicFlags::empty(),
11235        )
11236    }
11237}
11238
11239#[must_use = "FIDL methods require a response to be sent"]
11240#[derive(Debug)]
11241pub struct VirtioWaylandStartResponder {
11242    control_handle: std::mem::ManuallyDrop<VirtioWaylandControlHandle>,
11243    tx_id: u32,
11244}
11245
11246/// Set the the channel to be shutdown (see [`VirtioWaylandControlHandle::shutdown`])
11247/// if the responder is dropped without sending a response, so that the client
11248/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11249impl std::ops::Drop for VirtioWaylandStartResponder {
11250    fn drop(&mut self) {
11251        self.control_handle.shutdown();
11252        // Safety: drops once, never accessed again
11253        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11254    }
11255}
11256
11257impl fidl::endpoints::Responder for VirtioWaylandStartResponder {
11258    type ControlHandle = VirtioWaylandControlHandle;
11259
11260    fn control_handle(&self) -> &VirtioWaylandControlHandle {
11261        &self.control_handle
11262    }
11263
11264    fn drop_without_shutdown(mut self) {
11265        // Safety: drops once, never accessed again due to mem::forget
11266        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11267        // Prevent Drop from running (which would shut down the channel)
11268        std::mem::forget(self);
11269    }
11270}
11271
11272impl VirtioWaylandStartResponder {
11273    /// Sends a response to the FIDL transaction.
11274    ///
11275    /// Sets the channel to shutdown if an error occurs.
11276    pub fn send(self) -> Result<(), fidl::Error> {
11277        let _result = self.send_raw();
11278        if _result.is_err() {
11279            self.control_handle.shutdown();
11280        }
11281        self.drop_without_shutdown();
11282        _result
11283    }
11284
11285    /// Similar to "send" but does not shutdown the channel if an error occurs.
11286    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11287        let _result = self.send_raw();
11288        self.drop_without_shutdown();
11289        _result
11290    }
11291
11292    fn send_raw(&self) -> Result<(), fidl::Error> {
11293        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11294            (),
11295            self.tx_id,
11296            0x1f60e084e30deee6,
11297            fidl::encoding::DynamicFlags::empty(),
11298        )
11299    }
11300}
11301
11302#[must_use = "FIDL methods require a response to be sent"]
11303#[derive(Debug)]
11304pub struct VirtioWaylandStartWithWaylandServer_Responder {
11305    control_handle: std::mem::ManuallyDrop<VirtioWaylandControlHandle>,
11306    tx_id: u32,
11307}
11308
11309/// Set the the channel to be shutdown (see [`VirtioWaylandControlHandle::shutdown`])
11310/// if the responder is dropped without sending a response, so that the client
11311/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11312impl std::ops::Drop for VirtioWaylandStartWithWaylandServer_Responder {
11313    fn drop(&mut self) {
11314        self.control_handle.shutdown();
11315        // Safety: drops once, never accessed again
11316        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11317    }
11318}
11319
11320impl fidl::endpoints::Responder for VirtioWaylandStartWithWaylandServer_Responder {
11321    type ControlHandle = VirtioWaylandControlHandle;
11322
11323    fn control_handle(&self) -> &VirtioWaylandControlHandle {
11324        &self.control_handle
11325    }
11326
11327    fn drop_without_shutdown(mut self) {
11328        // Safety: drops once, never accessed again due to mem::forget
11329        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11330        // Prevent Drop from running (which would shut down the channel)
11331        std::mem::forget(self);
11332    }
11333}
11334
11335impl VirtioWaylandStartWithWaylandServer_Responder {
11336    /// Sends a response to the FIDL transaction.
11337    ///
11338    /// Sets the channel to shutdown if an error occurs.
11339    pub fn send(self) -> Result<(), fidl::Error> {
11340        let _result = self.send_raw();
11341        if _result.is_err() {
11342            self.control_handle.shutdown();
11343        }
11344        self.drop_without_shutdown();
11345        _result
11346    }
11347
11348    /// Similar to "send" but does not shutdown the channel if an error occurs.
11349    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11350        let _result = self.send_raw();
11351        self.drop_without_shutdown();
11352        _result
11353    }
11354
11355    fn send_raw(&self) -> Result<(), fidl::Error> {
11356        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11357            (),
11358            self.tx_id,
11359            0x3f2e38dfb60077e9,
11360            fidl::encoding::DynamicFlags::empty(),
11361        )
11362    }
11363}
11364
11365#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11366pub struct VirtioWaylandImporterMarker;
11367
11368impl fidl::endpoints::ProtocolMarker for VirtioWaylandImporterMarker {
11369    type Proxy = VirtioWaylandImporterProxy;
11370    type RequestStream = VirtioWaylandImporterRequestStream;
11371    #[cfg(target_os = "fuchsia")]
11372    type SynchronousProxy = VirtioWaylandImporterSynchronousProxy;
11373
11374    const DEBUG_NAME: &'static str = "(anonymous) VirtioWaylandImporter";
11375}
11376
11377pub trait VirtioWaylandImporterProxyInterface: Send + Sync {
11378    type ImportImageResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
11379    fn r#import_image(&self, image: VirtioImage) -> Self::ImportImageResponseFut;
11380    type ExportImageResponseFut: std::future::Future<Output = Result<(i32, Option<Box<VirtioImage>>), fidl::Error>>
11381        + Send;
11382    fn r#export_image(&self, vfd_id: u32) -> Self::ExportImageResponseFut;
11383}
11384#[derive(Debug)]
11385#[cfg(target_os = "fuchsia")]
11386pub struct VirtioWaylandImporterSynchronousProxy {
11387    client: fidl::client::sync::Client,
11388}
11389
11390#[cfg(target_os = "fuchsia")]
11391impl fidl::endpoints::SynchronousProxy for VirtioWaylandImporterSynchronousProxy {
11392    type Proxy = VirtioWaylandImporterProxy;
11393    type Protocol = VirtioWaylandImporterMarker;
11394
11395    fn from_channel(inner: fidl::Channel) -> Self {
11396        Self::new(inner)
11397    }
11398
11399    fn into_channel(self) -> fidl::Channel {
11400        self.client.into_channel()
11401    }
11402
11403    fn as_channel(&self) -> &fidl::Channel {
11404        self.client.as_channel()
11405    }
11406}
11407
11408#[cfg(target_os = "fuchsia")]
11409impl VirtioWaylandImporterSynchronousProxy {
11410    pub fn new(channel: fidl::Channel) -> Self {
11411        let protocol_name =
11412            <VirtioWaylandImporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11413        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
11414    }
11415
11416    pub fn into_channel(self) -> fidl::Channel {
11417        self.client.into_channel()
11418    }
11419
11420    /// Waits until an event arrives and returns it. It is safe for other
11421    /// threads to make concurrent requests while waiting for an event.
11422    pub fn wait_for_event(
11423        &self,
11424        deadline: zx::MonotonicInstant,
11425    ) -> Result<VirtioWaylandImporterEvent, fidl::Error> {
11426        VirtioWaylandImporterEvent::decode(self.client.wait_for_event(deadline)?)
11427    }
11428
11429    pub fn r#import_image(
11430        &self,
11431        mut image: VirtioImage,
11432        ___deadline: zx::MonotonicInstant,
11433    ) -> Result<u32, fidl::Error> {
11434        let _response = self.client.send_query::<
11435            VirtioWaylandImporterImportImageRequest,
11436            VirtioWaylandImporterImportImageResponse,
11437        >(
11438            (&mut image,),
11439            0x3f8f3f75c34de5c,
11440            fidl::encoding::DynamicFlags::empty(),
11441            ___deadline,
11442        )?;
11443        Ok(_response.vfd_id)
11444    }
11445
11446    pub fn r#export_image(
11447        &self,
11448        mut vfd_id: u32,
11449        ___deadline: zx::MonotonicInstant,
11450    ) -> Result<(i32, Option<Box<VirtioImage>>), fidl::Error> {
11451        let _response = self.client.send_query::<
11452            VirtioWaylandImporterExportImageRequest,
11453            VirtioWaylandImporterExportImageResponse,
11454        >(
11455            (vfd_id,),
11456            0x25a33daa7c0307c4,
11457            fidl::encoding::DynamicFlags::empty(),
11458            ___deadline,
11459        )?;
11460        Ok((_response.status, _response.image))
11461    }
11462}
11463
11464#[cfg(target_os = "fuchsia")]
11465impl From<VirtioWaylandImporterSynchronousProxy> for zx::Handle {
11466    fn from(value: VirtioWaylandImporterSynchronousProxy) -> Self {
11467        value.into_channel().into()
11468    }
11469}
11470
11471#[cfg(target_os = "fuchsia")]
11472impl From<fidl::Channel> for VirtioWaylandImporterSynchronousProxy {
11473    fn from(value: fidl::Channel) -> Self {
11474        Self::new(value)
11475    }
11476}
11477
11478#[derive(Debug, Clone)]
11479pub struct VirtioWaylandImporterProxy {
11480    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
11481}
11482
11483impl fidl::endpoints::Proxy for VirtioWaylandImporterProxy {
11484    type Protocol = VirtioWaylandImporterMarker;
11485
11486    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
11487        Self::new(inner)
11488    }
11489
11490    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
11491        self.client.into_channel().map_err(|client| Self { client })
11492    }
11493
11494    fn as_channel(&self) -> &::fidl::AsyncChannel {
11495        self.client.as_channel()
11496    }
11497}
11498
11499impl VirtioWaylandImporterProxy {
11500    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioWaylandImporter.
11501    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
11502        let protocol_name =
11503            <VirtioWaylandImporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11504        Self { client: fidl::client::Client::new(channel, protocol_name) }
11505    }
11506
11507    /// Get a Stream of events from the remote end of the protocol.
11508    ///
11509    /// # Panics
11510    ///
11511    /// Panics if the event stream was already taken.
11512    pub fn take_event_stream(&self) -> VirtioWaylandImporterEventStream {
11513        VirtioWaylandImporterEventStream { event_receiver: self.client.take_event_receiver() }
11514    }
11515
11516    pub fn r#import_image(
11517        &self,
11518        mut image: VirtioImage,
11519    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
11520        VirtioWaylandImporterProxyInterface::r#import_image(self, image)
11521    }
11522
11523    pub fn r#export_image(
11524        &self,
11525        mut vfd_id: u32,
11526    ) -> fidl::client::QueryResponseFut<
11527        (i32, Option<Box<VirtioImage>>),
11528        fidl::encoding::DefaultFuchsiaResourceDialect,
11529    > {
11530        VirtioWaylandImporterProxyInterface::r#export_image(self, vfd_id)
11531    }
11532}
11533
11534impl VirtioWaylandImporterProxyInterface for VirtioWaylandImporterProxy {
11535    type ImportImageResponseFut =
11536        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
11537    fn r#import_image(&self, mut image: VirtioImage) -> Self::ImportImageResponseFut {
11538        fn _decode(
11539            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11540        ) -> Result<u32, fidl::Error> {
11541            let _response = fidl::client::decode_transaction_body::<
11542                VirtioWaylandImporterImportImageResponse,
11543                fidl::encoding::DefaultFuchsiaResourceDialect,
11544                0x3f8f3f75c34de5c,
11545            >(_buf?)?;
11546            Ok(_response.vfd_id)
11547        }
11548        self.client.send_query_and_decode::<VirtioWaylandImporterImportImageRequest, u32>(
11549            (&mut image,),
11550            0x3f8f3f75c34de5c,
11551            fidl::encoding::DynamicFlags::empty(),
11552            _decode,
11553        )
11554    }
11555
11556    type ExportImageResponseFut = fidl::client::QueryResponseFut<
11557        (i32, Option<Box<VirtioImage>>),
11558        fidl::encoding::DefaultFuchsiaResourceDialect,
11559    >;
11560    fn r#export_image(&self, mut vfd_id: u32) -> Self::ExportImageResponseFut {
11561        fn _decode(
11562            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11563        ) -> Result<(i32, Option<Box<VirtioImage>>), fidl::Error> {
11564            let _response = fidl::client::decode_transaction_body::<
11565                VirtioWaylandImporterExportImageResponse,
11566                fidl::encoding::DefaultFuchsiaResourceDialect,
11567                0x25a33daa7c0307c4,
11568            >(_buf?)?;
11569            Ok((_response.status, _response.image))
11570        }
11571        self.client.send_query_and_decode::<
11572            VirtioWaylandImporterExportImageRequest,
11573            (i32, Option<Box<VirtioImage>>),
11574        >(
11575            (vfd_id,),
11576            0x25a33daa7c0307c4,
11577            fidl::encoding::DynamicFlags::empty(),
11578            _decode,
11579        )
11580    }
11581}
11582
11583pub struct VirtioWaylandImporterEventStream {
11584    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11585}
11586
11587impl std::marker::Unpin for VirtioWaylandImporterEventStream {}
11588
11589impl futures::stream::FusedStream for VirtioWaylandImporterEventStream {
11590    fn is_terminated(&self) -> bool {
11591        self.event_receiver.is_terminated()
11592    }
11593}
11594
11595impl futures::Stream for VirtioWaylandImporterEventStream {
11596    type Item = Result<VirtioWaylandImporterEvent, fidl::Error>;
11597
11598    fn poll_next(
11599        mut self: std::pin::Pin<&mut Self>,
11600        cx: &mut std::task::Context<'_>,
11601    ) -> std::task::Poll<Option<Self::Item>> {
11602        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11603            &mut self.event_receiver,
11604            cx
11605        )?) {
11606            Some(buf) => std::task::Poll::Ready(Some(VirtioWaylandImporterEvent::decode(buf))),
11607            None => std::task::Poll::Ready(None),
11608        }
11609    }
11610}
11611
11612#[derive(Debug)]
11613pub enum VirtioWaylandImporterEvent {}
11614
11615impl VirtioWaylandImporterEvent {
11616    /// Decodes a message buffer as a [`VirtioWaylandImporterEvent`].
11617    fn decode(
11618        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11619    ) -> Result<VirtioWaylandImporterEvent, fidl::Error> {
11620        let (bytes, _handles) = buf.split_mut();
11621        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11622        debug_assert_eq!(tx_header.tx_id, 0);
11623        match tx_header.ordinal {
11624            _ => Err(fidl::Error::UnknownOrdinal {
11625                ordinal: tx_header.ordinal,
11626                protocol_name:
11627                    <VirtioWaylandImporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11628            }),
11629        }
11630    }
11631}
11632
11633/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioWaylandImporter.
11634pub struct VirtioWaylandImporterRequestStream {
11635    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11636    is_terminated: bool,
11637}
11638
11639impl std::marker::Unpin for VirtioWaylandImporterRequestStream {}
11640
11641impl futures::stream::FusedStream for VirtioWaylandImporterRequestStream {
11642    fn is_terminated(&self) -> bool {
11643        self.is_terminated
11644    }
11645}
11646
11647impl fidl::endpoints::RequestStream for VirtioWaylandImporterRequestStream {
11648    type Protocol = VirtioWaylandImporterMarker;
11649    type ControlHandle = VirtioWaylandImporterControlHandle;
11650
11651    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11652        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11653    }
11654
11655    fn control_handle(&self) -> Self::ControlHandle {
11656        VirtioWaylandImporterControlHandle { inner: self.inner.clone() }
11657    }
11658
11659    fn into_inner(
11660        self,
11661    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11662    {
11663        (self.inner, self.is_terminated)
11664    }
11665
11666    fn from_inner(
11667        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11668        is_terminated: bool,
11669    ) -> Self {
11670        Self { inner, is_terminated }
11671    }
11672}
11673
11674impl futures::Stream for VirtioWaylandImporterRequestStream {
11675    type Item = Result<VirtioWaylandImporterRequest, fidl::Error>;
11676
11677    fn poll_next(
11678        mut self: std::pin::Pin<&mut Self>,
11679        cx: &mut std::task::Context<'_>,
11680    ) -> std::task::Poll<Option<Self::Item>> {
11681        let this = &mut *self;
11682        if this.inner.check_shutdown(cx) {
11683            this.is_terminated = true;
11684            return std::task::Poll::Ready(None);
11685        }
11686        if this.is_terminated {
11687            panic!("polled VirtioWaylandImporterRequestStream after completion");
11688        }
11689        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11690            |bytes, handles| {
11691                match this.inner.channel().read_etc(cx, bytes, handles) {
11692                    std::task::Poll::Ready(Ok(())) => {}
11693                    std::task::Poll::Pending => return std::task::Poll::Pending,
11694                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11695                        this.is_terminated = true;
11696                        return std::task::Poll::Ready(None);
11697                    }
11698                    std::task::Poll::Ready(Err(e)) => {
11699                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11700                            e.into(),
11701                        ))))
11702                    }
11703                }
11704
11705                // A message has been received from the channel
11706                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11707
11708                std::task::Poll::Ready(Some(match header.ordinal {
11709                0x3f8f3f75c34de5c => {
11710                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11711                    let mut req = fidl::new_empty!(VirtioWaylandImporterImportImageRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
11712                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandImporterImportImageRequest>(&header, _body_bytes, handles, &mut req)?;
11713                    let control_handle = VirtioWaylandImporterControlHandle {
11714                        inner: this.inner.clone(),
11715                    };
11716                    Ok(VirtioWaylandImporterRequest::ImportImage {image: req.image,
11717
11718                        responder: VirtioWaylandImporterImportImageResponder {
11719                            control_handle: std::mem::ManuallyDrop::new(control_handle),
11720                            tx_id: header.tx_id,
11721                        },
11722                    })
11723                }
11724                0x25a33daa7c0307c4 => {
11725                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11726                    let mut req = fidl::new_empty!(VirtioWaylandImporterExportImageRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
11727                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioWaylandImporterExportImageRequest>(&header, _body_bytes, handles, &mut req)?;
11728                    let control_handle = VirtioWaylandImporterControlHandle {
11729                        inner: this.inner.clone(),
11730                    };
11731                    Ok(VirtioWaylandImporterRequest::ExportImage {vfd_id: req.vfd_id,
11732
11733                        responder: VirtioWaylandImporterExportImageResponder {
11734                            control_handle: std::mem::ManuallyDrop::new(control_handle),
11735                            tx_id: header.tx_id,
11736                        },
11737                    })
11738                }
11739                _ => Err(fidl::Error::UnknownOrdinal {
11740                    ordinal: header.ordinal,
11741                    protocol_name: <VirtioWaylandImporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11742                }),
11743            }))
11744            },
11745        )
11746    }
11747}
11748
11749#[derive(Debug)]
11750pub enum VirtioWaylandImporterRequest {
11751    ImportImage { image: VirtioImage, responder: VirtioWaylandImporterImportImageResponder },
11752    ExportImage { vfd_id: u32, responder: VirtioWaylandImporterExportImageResponder },
11753}
11754
11755impl VirtioWaylandImporterRequest {
11756    #[allow(irrefutable_let_patterns)]
11757    pub fn into_import_image(
11758        self,
11759    ) -> Option<(VirtioImage, VirtioWaylandImporterImportImageResponder)> {
11760        if let VirtioWaylandImporterRequest::ImportImage { image, responder } = self {
11761            Some((image, responder))
11762        } else {
11763            None
11764        }
11765    }
11766
11767    #[allow(irrefutable_let_patterns)]
11768    pub fn into_export_image(self) -> Option<(u32, VirtioWaylandImporterExportImageResponder)> {
11769        if let VirtioWaylandImporterRequest::ExportImage { vfd_id, responder } = self {
11770            Some((vfd_id, responder))
11771        } else {
11772            None
11773        }
11774    }
11775
11776    /// Name of the method defined in FIDL
11777    pub fn method_name(&self) -> &'static str {
11778        match *self {
11779            VirtioWaylandImporterRequest::ImportImage { .. } => "import_image",
11780            VirtioWaylandImporterRequest::ExportImage { .. } => "export_image",
11781        }
11782    }
11783}
11784
11785#[derive(Debug, Clone)]
11786pub struct VirtioWaylandImporterControlHandle {
11787    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11788}
11789
11790impl fidl::endpoints::ControlHandle for VirtioWaylandImporterControlHandle {
11791    fn shutdown(&self) {
11792        self.inner.shutdown()
11793    }
11794    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11795        self.inner.shutdown_with_epitaph(status)
11796    }
11797
11798    fn is_closed(&self) -> bool {
11799        self.inner.channel().is_closed()
11800    }
11801    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11802        self.inner.channel().on_closed()
11803    }
11804
11805    #[cfg(target_os = "fuchsia")]
11806    fn signal_peer(
11807        &self,
11808        clear_mask: zx::Signals,
11809        set_mask: zx::Signals,
11810    ) -> Result<(), zx_status::Status> {
11811        use fidl::Peered;
11812        self.inner.channel().signal_peer(clear_mask, set_mask)
11813    }
11814}
11815
11816impl VirtioWaylandImporterControlHandle {}
11817
11818#[must_use = "FIDL methods require a response to be sent"]
11819#[derive(Debug)]
11820pub struct VirtioWaylandImporterImportImageResponder {
11821    control_handle: std::mem::ManuallyDrop<VirtioWaylandImporterControlHandle>,
11822    tx_id: u32,
11823}
11824
11825/// Set the the channel to be shutdown (see [`VirtioWaylandImporterControlHandle::shutdown`])
11826/// if the responder is dropped without sending a response, so that the client
11827/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11828impl std::ops::Drop for VirtioWaylandImporterImportImageResponder {
11829    fn drop(&mut self) {
11830        self.control_handle.shutdown();
11831        // Safety: drops once, never accessed again
11832        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11833    }
11834}
11835
11836impl fidl::endpoints::Responder for VirtioWaylandImporterImportImageResponder {
11837    type ControlHandle = VirtioWaylandImporterControlHandle;
11838
11839    fn control_handle(&self) -> &VirtioWaylandImporterControlHandle {
11840        &self.control_handle
11841    }
11842
11843    fn drop_without_shutdown(mut self) {
11844        // Safety: drops once, never accessed again due to mem::forget
11845        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11846        // Prevent Drop from running (which would shut down the channel)
11847        std::mem::forget(self);
11848    }
11849}
11850
11851impl VirtioWaylandImporterImportImageResponder {
11852    /// Sends a response to the FIDL transaction.
11853    ///
11854    /// Sets the channel to shutdown if an error occurs.
11855    pub fn send(self, mut vfd_id: u32) -> Result<(), fidl::Error> {
11856        let _result = self.send_raw(vfd_id);
11857        if _result.is_err() {
11858            self.control_handle.shutdown();
11859        }
11860        self.drop_without_shutdown();
11861        _result
11862    }
11863
11864    /// Similar to "send" but does not shutdown the channel if an error occurs.
11865    pub fn send_no_shutdown_on_err(self, mut vfd_id: u32) -> Result<(), fidl::Error> {
11866        let _result = self.send_raw(vfd_id);
11867        self.drop_without_shutdown();
11868        _result
11869    }
11870
11871    fn send_raw(&self, mut vfd_id: u32) -> Result<(), fidl::Error> {
11872        self.control_handle.inner.send::<VirtioWaylandImporterImportImageResponse>(
11873            (vfd_id,),
11874            self.tx_id,
11875            0x3f8f3f75c34de5c,
11876            fidl::encoding::DynamicFlags::empty(),
11877        )
11878    }
11879}
11880
11881#[must_use = "FIDL methods require a response to be sent"]
11882#[derive(Debug)]
11883pub struct VirtioWaylandImporterExportImageResponder {
11884    control_handle: std::mem::ManuallyDrop<VirtioWaylandImporterControlHandle>,
11885    tx_id: u32,
11886}
11887
11888/// Set the the channel to be shutdown (see [`VirtioWaylandImporterControlHandle::shutdown`])
11889/// if the responder is dropped without sending a response, so that the client
11890/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11891impl std::ops::Drop for VirtioWaylandImporterExportImageResponder {
11892    fn drop(&mut self) {
11893        self.control_handle.shutdown();
11894        // Safety: drops once, never accessed again
11895        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11896    }
11897}
11898
11899impl fidl::endpoints::Responder for VirtioWaylandImporterExportImageResponder {
11900    type ControlHandle = VirtioWaylandImporterControlHandle;
11901
11902    fn control_handle(&self) -> &VirtioWaylandImporterControlHandle {
11903        &self.control_handle
11904    }
11905
11906    fn drop_without_shutdown(mut self) {
11907        // Safety: drops once, never accessed again due to mem::forget
11908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11909        // Prevent Drop from running (which would shut down the channel)
11910        std::mem::forget(self);
11911    }
11912}
11913
11914impl VirtioWaylandImporterExportImageResponder {
11915    /// Sends a response to the FIDL transaction.
11916    ///
11917    /// Sets the channel to shutdown if an error occurs.
11918    pub fn send(self, mut status: i32, mut image: Option<VirtioImage>) -> Result<(), fidl::Error> {
11919        let _result = self.send_raw(status, image);
11920        if _result.is_err() {
11921            self.control_handle.shutdown();
11922        }
11923        self.drop_without_shutdown();
11924        _result
11925    }
11926
11927    /// Similar to "send" but does not shutdown the channel if an error occurs.
11928    pub fn send_no_shutdown_on_err(
11929        self,
11930        mut status: i32,
11931        mut image: Option<VirtioImage>,
11932    ) -> Result<(), fidl::Error> {
11933        let _result = self.send_raw(status, image);
11934        self.drop_without_shutdown();
11935        _result
11936    }
11937
11938    fn send_raw(&self, mut status: i32, mut image: Option<VirtioImage>) -> Result<(), fidl::Error> {
11939        self.control_handle.inner.send::<VirtioWaylandImporterExportImageResponse>(
11940            (status, image.as_mut()),
11941            self.tx_id,
11942            0x25a33daa7c0307c4,
11943            fidl::encoding::DynamicFlags::empty(),
11944        )
11945    }
11946}
11947
11948mod internal {
11949    use super::*;
11950
11951    impl fidl::encoding::ResourceTypeMarker for StartInfo {
11952        type Borrowed<'a> = &'a mut Self;
11953        fn take_or_borrow<'a>(
11954            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11955        ) -> Self::Borrowed<'a> {
11956            value
11957        }
11958    }
11959
11960    unsafe impl fidl::encoding::TypeMarker for StartInfo {
11961        type Owned = Self;
11962
11963        #[inline(always)]
11964        fn inline_align(_context: fidl::encoding::Context) -> usize {
11965            8
11966        }
11967
11968        #[inline(always)]
11969        fn inline_size(_context: fidl::encoding::Context) -> usize {
11970            32
11971        }
11972    }
11973
11974    unsafe impl fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
11975        for &mut StartInfo
11976    {
11977        #[inline]
11978        unsafe fn encode(
11979            self,
11980            encoder: &mut fidl::encoding::Encoder<
11981                '_,
11982                fidl::encoding::DefaultFuchsiaResourceDialect,
11983            >,
11984            offset: usize,
11985            _depth: fidl::encoding::Depth,
11986        ) -> fidl::Result<()> {
11987            encoder.debug_check_bounds::<StartInfo>(offset);
11988            // Delegate to tuple encoding.
11989            fidl::encoding::Encode::<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11990                (
11991                    <Trap as fidl::encoding::ValueTypeMarker>::borrow(&self.trap),
11992                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Guest, { fidl::ObjectType::GUEST.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
11993                    <fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.event),
11994                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
11995                ),
11996                encoder, offset, _depth
11997            )
11998        }
11999    }
12000    unsafe impl<
12001            T0: fidl::encoding::Encode<Trap, fidl::encoding::DefaultFuchsiaResourceDialect>,
12002            T1: fidl::encoding::Encode<
12003                fidl::encoding::Optional<
12004                    fidl::encoding::HandleType<
12005                        fidl::Guest,
12006                        { fidl::ObjectType::GUEST.into_raw() },
12007                        2147483648,
12008                    >,
12009                >,
12010                fidl::encoding::DefaultFuchsiaResourceDialect,
12011            >,
12012            T2: fidl::encoding::Encode<
12013                fidl::encoding::HandleType<
12014                    fidl::Event,
12015                    { fidl::ObjectType::EVENT.into_raw() },
12016                    2147483648,
12017                >,
12018                fidl::encoding::DefaultFuchsiaResourceDialect,
12019            >,
12020            T3: fidl::encoding::Encode<
12021                fidl::encoding::HandleType<
12022                    fidl::Vmo,
12023                    { fidl::ObjectType::VMO.into_raw() },
12024                    2147483648,
12025                >,
12026                fidl::encoding::DefaultFuchsiaResourceDialect,
12027            >,
12028        > fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
12029        for (T0, T1, T2, T3)
12030    {
12031        #[inline]
12032        unsafe fn encode(
12033            self,
12034            encoder: &mut fidl::encoding::Encoder<
12035                '_,
12036                fidl::encoding::DefaultFuchsiaResourceDialect,
12037            >,
12038            offset: usize,
12039            depth: fidl::encoding::Depth,
12040        ) -> fidl::Result<()> {
12041            encoder.debug_check_bounds::<StartInfo>(offset);
12042            // Zero out padding regions. There's no need to apply masks
12043            // because the unmasked parts will be overwritten by fields.
12044            unsafe {
12045                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
12046                (ptr as *mut u64).write_unaligned(0);
12047            }
12048            // Write the fields.
12049            self.0.encode(encoder, offset + 0, depth)?;
12050            self.1.encode(encoder, offset + 16, depth)?;
12051            self.2.encode(encoder, offset + 20, depth)?;
12052            self.3.encode(encoder, offset + 24, depth)?;
12053            Ok(())
12054        }
12055    }
12056
12057    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for StartInfo {
12058        #[inline(always)]
12059        fn new_empty() -> Self {
12060            Self {
12061                trap: fidl::new_empty!(Trap, fidl::encoding::DefaultFuchsiaResourceDialect),
12062                guest: fidl::new_empty!(
12063                    fidl::encoding::Optional<
12064                        fidl::encoding::HandleType<
12065                            fidl::Guest,
12066                            { fidl::ObjectType::GUEST.into_raw() },
12067                            2147483648,
12068                        >,
12069                    >,
12070                    fidl::encoding::DefaultFuchsiaResourceDialect
12071                ),
12072                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12073                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12074            }
12075        }
12076
12077        #[inline]
12078        unsafe fn decode(
12079            &mut self,
12080            decoder: &mut fidl::encoding::Decoder<
12081                '_,
12082                fidl::encoding::DefaultFuchsiaResourceDialect,
12083            >,
12084            offset: usize,
12085            _depth: fidl::encoding::Depth,
12086        ) -> fidl::Result<()> {
12087            decoder.debug_check_bounds::<Self>(offset);
12088            // Verify that padding bytes are zero.
12089            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
12090            let padval = unsafe { (ptr as *const u64).read_unaligned() };
12091            let mask = 0xffffffff00000000u64;
12092            let maskedval = padval & mask;
12093            if maskedval != 0 {
12094                return Err(fidl::Error::NonZeroPadding {
12095                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
12096                });
12097            }
12098            fidl::decode!(
12099                Trap,
12100                fidl::encoding::DefaultFuchsiaResourceDialect,
12101                &mut self.trap,
12102                decoder,
12103                offset + 0,
12104                _depth
12105            )?;
12106            fidl::decode!(
12107                fidl::encoding::Optional<
12108                    fidl::encoding::HandleType<
12109                        fidl::Guest,
12110                        { fidl::ObjectType::GUEST.into_raw() },
12111                        2147483648,
12112                    >,
12113                >,
12114                fidl::encoding::DefaultFuchsiaResourceDialect,
12115                &mut self.guest,
12116                decoder,
12117                offset + 16,
12118                _depth
12119            )?;
12120            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 20, _depth)?;
12121            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 24, _depth)?;
12122            Ok(())
12123        }
12124    }
12125
12126    impl fidl::encoding::ResourceTypeMarker for VirtioBalloonStartRequest {
12127        type Borrowed<'a> = &'a mut Self;
12128        fn take_or_borrow<'a>(
12129            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12130        ) -> Self::Borrowed<'a> {
12131            value
12132        }
12133    }
12134
12135    unsafe impl fidl::encoding::TypeMarker for VirtioBalloonStartRequest {
12136        type Owned = Self;
12137
12138        #[inline(always)]
12139        fn inline_align(_context: fidl::encoding::Context) -> usize {
12140            8
12141        }
12142
12143        #[inline(always)]
12144        fn inline_size(_context: fidl::encoding::Context) -> usize {
12145            32
12146        }
12147    }
12148
12149    unsafe impl
12150        fidl::encoding::Encode<
12151            VirtioBalloonStartRequest,
12152            fidl::encoding::DefaultFuchsiaResourceDialect,
12153        > for &mut VirtioBalloonStartRequest
12154    {
12155        #[inline]
12156        unsafe fn encode(
12157            self,
12158            encoder: &mut fidl::encoding::Encoder<
12159                '_,
12160                fidl::encoding::DefaultFuchsiaResourceDialect,
12161            >,
12162            offset: usize,
12163            _depth: fidl::encoding::Depth,
12164        ) -> fidl::Result<()> {
12165            encoder.debug_check_bounds::<VirtioBalloonStartRequest>(offset);
12166            // Delegate to tuple encoding.
12167            fidl::encoding::Encode::<
12168                VirtioBalloonStartRequest,
12169                fidl::encoding::DefaultFuchsiaResourceDialect,
12170            >::encode(
12171                (<StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12172                    &mut self.start_info,
12173                ),),
12174                encoder,
12175                offset,
12176                _depth,
12177            )
12178        }
12179    }
12180    unsafe impl<T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>>
12181        fidl::encoding::Encode<
12182            VirtioBalloonStartRequest,
12183            fidl::encoding::DefaultFuchsiaResourceDialect,
12184        > for (T0,)
12185    {
12186        #[inline]
12187        unsafe fn encode(
12188            self,
12189            encoder: &mut fidl::encoding::Encoder<
12190                '_,
12191                fidl::encoding::DefaultFuchsiaResourceDialect,
12192            >,
12193            offset: usize,
12194            depth: fidl::encoding::Depth,
12195        ) -> fidl::Result<()> {
12196            encoder.debug_check_bounds::<VirtioBalloonStartRequest>(offset);
12197            // Zero out padding regions. There's no need to apply masks
12198            // because the unmasked parts will be overwritten by fields.
12199            // Write the fields.
12200            self.0.encode(encoder, offset + 0, depth)?;
12201            Ok(())
12202        }
12203    }
12204
12205    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12206        for VirtioBalloonStartRequest
12207    {
12208        #[inline(always)]
12209        fn new_empty() -> Self {
12210            Self {
12211                start_info: fidl::new_empty!(
12212                    StartInfo,
12213                    fidl::encoding::DefaultFuchsiaResourceDialect
12214                ),
12215            }
12216        }
12217
12218        #[inline]
12219        unsafe fn decode(
12220            &mut self,
12221            decoder: &mut fidl::encoding::Decoder<
12222                '_,
12223                fidl::encoding::DefaultFuchsiaResourceDialect,
12224            >,
12225            offset: usize,
12226            _depth: fidl::encoding::Depth,
12227        ) -> fidl::Result<()> {
12228            decoder.debug_check_bounds::<Self>(offset);
12229            // Verify that padding bytes are zero.
12230            fidl::decode!(
12231                StartInfo,
12232                fidl::encoding::DefaultFuchsiaResourceDialect,
12233                &mut self.start_info,
12234                decoder,
12235                offset + 0,
12236                _depth
12237            )?;
12238            Ok(())
12239        }
12240    }
12241
12242    impl fidl::encoding::ResourceTypeMarker for VirtioBlockStartRequest {
12243        type Borrowed<'a> = &'a mut Self;
12244        fn take_or_borrow<'a>(
12245            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12246        ) -> Self::Borrowed<'a> {
12247            value
12248        }
12249    }
12250
12251    unsafe impl fidl::encoding::TypeMarker for VirtioBlockStartRequest {
12252        type Owned = Self;
12253
12254        #[inline(always)]
12255        fn inline_align(_context: fidl::encoding::Context) -> usize {
12256            8
12257        }
12258
12259        #[inline(always)]
12260        fn inline_size(_context: fidl::encoding::Context) -> usize {
12261            72
12262        }
12263    }
12264
12265    unsafe impl
12266        fidl::encoding::Encode<
12267            VirtioBlockStartRequest,
12268            fidl::encoding::DefaultFuchsiaResourceDialect,
12269        > for &mut VirtioBlockStartRequest
12270    {
12271        #[inline]
12272        unsafe fn encode(
12273            self,
12274            encoder: &mut fidl::encoding::Encoder<
12275                '_,
12276                fidl::encoding::DefaultFuchsiaResourceDialect,
12277            >,
12278            offset: usize,
12279            _depth: fidl::encoding::Depth,
12280        ) -> fidl::Result<()> {
12281            encoder.debug_check_bounds::<VirtioBlockStartRequest>(offset);
12282            // Delegate to tuple encoding.
12283            fidl::encoding::Encode::<VirtioBlockStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12284                (
12285                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.start_info),
12286                    <fidl_fuchsia_virtualization::BlockSpec as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.spec),
12287                ),
12288                encoder, offset, _depth
12289            )
12290        }
12291    }
12292    unsafe impl<
12293            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
12294            T1: fidl::encoding::Encode<
12295                fidl_fuchsia_virtualization::BlockSpec,
12296                fidl::encoding::DefaultFuchsiaResourceDialect,
12297            >,
12298        >
12299        fidl::encoding::Encode<
12300            VirtioBlockStartRequest,
12301            fidl::encoding::DefaultFuchsiaResourceDialect,
12302        > for (T0, T1)
12303    {
12304        #[inline]
12305        unsafe fn encode(
12306            self,
12307            encoder: &mut fidl::encoding::Encoder<
12308                '_,
12309                fidl::encoding::DefaultFuchsiaResourceDialect,
12310            >,
12311            offset: usize,
12312            depth: fidl::encoding::Depth,
12313        ) -> fidl::Result<()> {
12314            encoder.debug_check_bounds::<VirtioBlockStartRequest>(offset);
12315            // Zero out padding regions. There's no need to apply masks
12316            // because the unmasked parts will be overwritten by fields.
12317            // Write the fields.
12318            self.0.encode(encoder, offset + 0, depth)?;
12319            self.1.encode(encoder, offset + 32, depth)?;
12320            Ok(())
12321        }
12322    }
12323
12324    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12325        for VirtioBlockStartRequest
12326    {
12327        #[inline(always)]
12328        fn new_empty() -> Self {
12329            Self {
12330                start_info: fidl::new_empty!(
12331                    StartInfo,
12332                    fidl::encoding::DefaultFuchsiaResourceDialect
12333                ),
12334                spec: fidl::new_empty!(
12335                    fidl_fuchsia_virtualization::BlockSpec,
12336                    fidl::encoding::DefaultFuchsiaResourceDialect
12337                ),
12338            }
12339        }
12340
12341        #[inline]
12342        unsafe fn decode(
12343            &mut self,
12344            decoder: &mut fidl::encoding::Decoder<
12345                '_,
12346                fidl::encoding::DefaultFuchsiaResourceDialect,
12347            >,
12348            offset: usize,
12349            _depth: fidl::encoding::Depth,
12350        ) -> fidl::Result<()> {
12351            decoder.debug_check_bounds::<Self>(offset);
12352            // Verify that padding bytes are zero.
12353            fidl::decode!(
12354                StartInfo,
12355                fidl::encoding::DefaultFuchsiaResourceDialect,
12356                &mut self.start_info,
12357                decoder,
12358                offset + 0,
12359                _depth
12360            )?;
12361            fidl::decode!(
12362                fidl_fuchsia_virtualization::BlockSpec,
12363                fidl::encoding::DefaultFuchsiaResourceDialect,
12364                &mut self.spec,
12365                decoder,
12366                offset + 32,
12367                _depth
12368            )?;
12369            Ok(())
12370        }
12371    }
12372
12373    impl fidl::encoding::ResourceTypeMarker for VirtioConsoleStartRequest {
12374        type Borrowed<'a> = &'a mut Self;
12375        fn take_or_borrow<'a>(
12376            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12377        ) -> Self::Borrowed<'a> {
12378            value
12379        }
12380    }
12381
12382    unsafe impl fidl::encoding::TypeMarker for VirtioConsoleStartRequest {
12383        type Owned = Self;
12384
12385        #[inline(always)]
12386        fn inline_align(_context: fidl::encoding::Context) -> usize {
12387            8
12388        }
12389
12390        #[inline(always)]
12391        fn inline_size(_context: fidl::encoding::Context) -> usize {
12392            40
12393        }
12394    }
12395
12396    unsafe impl
12397        fidl::encoding::Encode<
12398            VirtioConsoleStartRequest,
12399            fidl::encoding::DefaultFuchsiaResourceDialect,
12400        > for &mut VirtioConsoleStartRequest
12401    {
12402        #[inline]
12403        unsafe fn encode(
12404            self,
12405            encoder: &mut fidl::encoding::Encoder<
12406                '_,
12407                fidl::encoding::DefaultFuchsiaResourceDialect,
12408            >,
12409            offset: usize,
12410            _depth: fidl::encoding::Depth,
12411        ) -> fidl::Result<()> {
12412            encoder.debug_check_bounds::<VirtioConsoleStartRequest>(offset);
12413            // Delegate to tuple encoding.
12414            fidl::encoding::Encode::<
12415                VirtioConsoleStartRequest,
12416                fidl::encoding::DefaultFuchsiaResourceDialect,
12417            >::encode(
12418                (
12419                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12420                        &mut self.start_info,
12421                    ),
12422                    <fidl::encoding::HandleType<
12423                        fidl::Socket,
12424                        { fidl::ObjectType::SOCKET.into_raw() },
12425                        2147483648,
12426                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12427                        &mut self.socket
12428                    ),
12429                ),
12430                encoder,
12431                offset,
12432                _depth,
12433            )
12434        }
12435    }
12436    unsafe impl<
12437            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
12438            T1: fidl::encoding::Encode<
12439                fidl::encoding::HandleType<
12440                    fidl::Socket,
12441                    { fidl::ObjectType::SOCKET.into_raw() },
12442                    2147483648,
12443                >,
12444                fidl::encoding::DefaultFuchsiaResourceDialect,
12445            >,
12446        >
12447        fidl::encoding::Encode<
12448            VirtioConsoleStartRequest,
12449            fidl::encoding::DefaultFuchsiaResourceDialect,
12450        > for (T0, T1)
12451    {
12452        #[inline]
12453        unsafe fn encode(
12454            self,
12455            encoder: &mut fidl::encoding::Encoder<
12456                '_,
12457                fidl::encoding::DefaultFuchsiaResourceDialect,
12458            >,
12459            offset: usize,
12460            depth: fidl::encoding::Depth,
12461        ) -> fidl::Result<()> {
12462            encoder.debug_check_bounds::<VirtioConsoleStartRequest>(offset);
12463            // Zero out padding regions. There's no need to apply masks
12464            // because the unmasked parts will be overwritten by fields.
12465            unsafe {
12466                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
12467                (ptr as *mut u64).write_unaligned(0);
12468            }
12469            // Write the fields.
12470            self.0.encode(encoder, offset + 0, depth)?;
12471            self.1.encode(encoder, offset + 32, depth)?;
12472            Ok(())
12473        }
12474    }
12475
12476    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12477        for VirtioConsoleStartRequest
12478    {
12479        #[inline(always)]
12480        fn new_empty() -> Self {
12481            Self {
12482                start_info: fidl::new_empty!(
12483                    StartInfo,
12484                    fidl::encoding::DefaultFuchsiaResourceDialect
12485                ),
12486                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12487            }
12488        }
12489
12490        #[inline]
12491        unsafe fn decode(
12492            &mut self,
12493            decoder: &mut fidl::encoding::Decoder<
12494                '_,
12495                fidl::encoding::DefaultFuchsiaResourceDialect,
12496            >,
12497            offset: usize,
12498            _depth: fidl::encoding::Depth,
12499        ) -> fidl::Result<()> {
12500            decoder.debug_check_bounds::<Self>(offset);
12501            // Verify that padding bytes are zero.
12502            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
12503            let padval = unsafe { (ptr as *const u64).read_unaligned() };
12504            let mask = 0xffffffff00000000u64;
12505            let maskedval = padval & mask;
12506            if maskedval != 0 {
12507                return Err(fidl::Error::NonZeroPadding {
12508                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
12509                });
12510            }
12511            fidl::decode!(
12512                StartInfo,
12513                fidl::encoding::DefaultFuchsiaResourceDialect,
12514                &mut self.start_info,
12515                decoder,
12516                offset + 0,
12517                _depth
12518            )?;
12519            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 32, _depth)?;
12520            Ok(())
12521        }
12522    }
12523
12524    impl fidl::encoding::ResourceTypeMarker for VirtioGpuStartRequest {
12525        type Borrowed<'a> = &'a mut Self;
12526        fn take_or_borrow<'a>(
12527            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12528        ) -> Self::Borrowed<'a> {
12529            value
12530        }
12531    }
12532
12533    unsafe impl fidl::encoding::TypeMarker for VirtioGpuStartRequest {
12534        type Owned = Self;
12535
12536        #[inline(always)]
12537        fn inline_align(_context: fidl::encoding::Context) -> usize {
12538            8
12539        }
12540
12541        #[inline(always)]
12542        fn inline_size(_context: fidl::encoding::Context) -> usize {
12543            40
12544        }
12545    }
12546
12547    unsafe impl
12548        fidl::encoding::Encode<VirtioGpuStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
12549        for &mut VirtioGpuStartRequest
12550    {
12551        #[inline]
12552        unsafe fn encode(
12553            self,
12554            encoder: &mut fidl::encoding::Encoder<
12555                '_,
12556                fidl::encoding::DefaultFuchsiaResourceDialect,
12557            >,
12558            offset: usize,
12559            _depth: fidl::encoding::Depth,
12560        ) -> fidl::Result<()> {
12561            encoder.debug_check_bounds::<VirtioGpuStartRequest>(offset);
12562            // Delegate to tuple encoding.
12563            fidl::encoding::Encode::<
12564                VirtioGpuStartRequest,
12565                fidl::encoding::DefaultFuchsiaResourceDialect,
12566            >::encode(
12567                (
12568                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12569                        &mut self.start_info,
12570                    ),
12571                    <fidl::encoding::Optional<
12572                        fidl::encoding::Endpoint<
12573                            fidl::endpoints::ClientEnd<
12574                                fidl_fuchsia_ui_input3::KeyboardListenerMarker,
12575                            >,
12576                        >,
12577                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12578                        &mut self.keyboard_listener,
12579                    ),
12580                    <fidl::encoding::Optional<
12581                        fidl::encoding::Endpoint<
12582                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
12583                        >,
12584                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12585                        &mut self.mouse_source,
12586                    ),
12587                ),
12588                encoder,
12589                offset,
12590                _depth,
12591            )
12592        }
12593    }
12594    unsafe impl<
12595            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
12596            T1: fidl::encoding::Encode<
12597                fidl::encoding::Optional<
12598                    fidl::encoding::Endpoint<
12599                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
12600                    >,
12601                >,
12602                fidl::encoding::DefaultFuchsiaResourceDialect,
12603            >,
12604            T2: fidl::encoding::Encode<
12605                fidl::encoding::Optional<
12606                    fidl::encoding::Endpoint<
12607                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
12608                    >,
12609                >,
12610                fidl::encoding::DefaultFuchsiaResourceDialect,
12611            >,
12612        >
12613        fidl::encoding::Encode<VirtioGpuStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
12614        for (T0, T1, T2)
12615    {
12616        #[inline]
12617        unsafe fn encode(
12618            self,
12619            encoder: &mut fidl::encoding::Encoder<
12620                '_,
12621                fidl::encoding::DefaultFuchsiaResourceDialect,
12622            >,
12623            offset: usize,
12624            depth: fidl::encoding::Depth,
12625        ) -> fidl::Result<()> {
12626            encoder.debug_check_bounds::<VirtioGpuStartRequest>(offset);
12627            // Zero out padding regions. There's no need to apply masks
12628            // because the unmasked parts will be overwritten by fields.
12629            // Write the fields.
12630            self.0.encode(encoder, offset + 0, depth)?;
12631            self.1.encode(encoder, offset + 32, depth)?;
12632            self.2.encode(encoder, offset + 36, depth)?;
12633            Ok(())
12634        }
12635    }
12636
12637    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12638        for VirtioGpuStartRequest
12639    {
12640        #[inline(always)]
12641        fn new_empty() -> Self {
12642            Self {
12643                start_info: fidl::new_empty!(
12644                    StartInfo,
12645                    fidl::encoding::DefaultFuchsiaResourceDialect
12646                ),
12647                keyboard_listener: fidl::new_empty!(
12648                    fidl::encoding::Optional<
12649                        fidl::encoding::Endpoint<
12650                            fidl::endpoints::ClientEnd<
12651                                fidl_fuchsia_ui_input3::KeyboardListenerMarker,
12652                            >,
12653                        >,
12654                    >,
12655                    fidl::encoding::DefaultFuchsiaResourceDialect
12656                ),
12657                mouse_source: fidl::new_empty!(
12658                    fidl::encoding::Optional<
12659                        fidl::encoding::Endpoint<
12660                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
12661                        >,
12662                    >,
12663                    fidl::encoding::DefaultFuchsiaResourceDialect
12664                ),
12665            }
12666        }
12667
12668        #[inline]
12669        unsafe fn decode(
12670            &mut self,
12671            decoder: &mut fidl::encoding::Decoder<
12672                '_,
12673                fidl::encoding::DefaultFuchsiaResourceDialect,
12674            >,
12675            offset: usize,
12676            _depth: fidl::encoding::Depth,
12677        ) -> fidl::Result<()> {
12678            decoder.debug_check_bounds::<Self>(offset);
12679            // Verify that padding bytes are zero.
12680            fidl::decode!(
12681                StartInfo,
12682                fidl::encoding::DefaultFuchsiaResourceDialect,
12683                &mut self.start_info,
12684                decoder,
12685                offset + 0,
12686                _depth
12687            )?;
12688            fidl::decode!(
12689                fidl::encoding::Optional<
12690                    fidl::encoding::Endpoint<
12691                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
12692                    >,
12693                >,
12694                fidl::encoding::DefaultFuchsiaResourceDialect,
12695                &mut self.keyboard_listener,
12696                decoder,
12697                offset + 32,
12698                _depth
12699            )?;
12700            fidl::decode!(
12701                fidl::encoding::Optional<
12702                    fidl::encoding::Endpoint<
12703                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
12704                    >,
12705                >,
12706                fidl::encoding::DefaultFuchsiaResourceDialect,
12707                &mut self.mouse_source,
12708                decoder,
12709                offset + 36,
12710                _depth
12711            )?;
12712            Ok(())
12713        }
12714    }
12715
12716    impl fidl::encoding::ResourceTypeMarker for VirtioImage {
12717        type Borrowed<'a> = &'a mut Self;
12718        fn take_or_borrow<'a>(
12719            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12720        ) -> Self::Borrowed<'a> {
12721            value
12722        }
12723    }
12724
12725    unsafe impl fidl::encoding::TypeMarker for VirtioImage {
12726        type Owned = Self;
12727
12728        #[inline(always)]
12729        fn inline_align(_context: fidl::encoding::Context) -> usize {
12730            8
12731        }
12732
12733        #[inline(always)]
12734        fn inline_size(_context: fidl::encoding::Context) -> usize {
12735            24
12736        }
12737    }
12738
12739    unsafe impl fidl::encoding::Encode<VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect>
12740        for &mut VirtioImage
12741    {
12742        #[inline]
12743        unsafe fn encode(
12744            self,
12745            encoder: &mut fidl::encoding::Encoder<
12746                '_,
12747                fidl::encoding::DefaultFuchsiaResourceDialect,
12748            >,
12749            offset: usize,
12750            _depth: fidl::encoding::Depth,
12751        ) -> fidl::Result<()> {
12752            encoder.debug_check_bounds::<VirtioImage>(offset);
12753            // Delegate to tuple encoding.
12754            fidl::encoding::Encode::<VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12755                (
12756                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
12757                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
12758                    <fidl::encoding::Vector<u8, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
12759                ),
12760                encoder, offset, _depth
12761            )
12762        }
12763    }
12764    unsafe impl<
12765            T0: fidl::encoding::Encode<
12766                fidl::encoding::HandleType<
12767                    fidl::Vmo,
12768                    { fidl::ObjectType::VMO.into_raw() },
12769                    2147483648,
12770                >,
12771                fidl::encoding::DefaultFuchsiaResourceDialect,
12772            >,
12773            T1: fidl::encoding::Encode<
12774                fidl::encoding::Optional<
12775                    fidl::encoding::HandleType<
12776                        fidl::EventPair,
12777                        { fidl::ObjectType::EVENTPAIR.into_raw() },
12778                        2147483648,
12779                    >,
12780                >,
12781                fidl::encoding::DefaultFuchsiaResourceDialect,
12782            >,
12783            T2: fidl::encoding::Encode<
12784                fidl::encoding::Vector<u8, 128>,
12785                fidl::encoding::DefaultFuchsiaResourceDialect,
12786            >,
12787        > fidl::encoding::Encode<VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect>
12788        for (T0, T1, T2)
12789    {
12790        #[inline]
12791        unsafe fn encode(
12792            self,
12793            encoder: &mut fidl::encoding::Encoder<
12794                '_,
12795                fidl::encoding::DefaultFuchsiaResourceDialect,
12796            >,
12797            offset: usize,
12798            depth: fidl::encoding::Depth,
12799        ) -> fidl::Result<()> {
12800            encoder.debug_check_bounds::<VirtioImage>(offset);
12801            // Zero out padding regions. There's no need to apply masks
12802            // because the unmasked parts will be overwritten by fields.
12803            // Write the fields.
12804            self.0.encode(encoder, offset + 0, depth)?;
12805            self.1.encode(encoder, offset + 4, depth)?;
12806            self.2.encode(encoder, offset + 8, depth)?;
12807            Ok(())
12808        }
12809    }
12810
12811    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioImage {
12812        #[inline(always)]
12813        fn new_empty() -> Self {
12814            Self {
12815                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12816                token: fidl::new_empty!(
12817                    fidl::encoding::Optional<
12818                        fidl::encoding::HandleType<
12819                            fidl::EventPair,
12820                            { fidl::ObjectType::EVENTPAIR.into_raw() },
12821                            2147483648,
12822                        >,
12823                    >,
12824                    fidl::encoding::DefaultFuchsiaResourceDialect
12825                ),
12826                info: fidl::new_empty!(fidl::encoding::Vector<u8, 128>, fidl::encoding::DefaultFuchsiaResourceDialect),
12827            }
12828        }
12829
12830        #[inline]
12831        unsafe fn decode(
12832            &mut self,
12833            decoder: &mut fidl::encoding::Decoder<
12834                '_,
12835                fidl::encoding::DefaultFuchsiaResourceDialect,
12836            >,
12837            offset: usize,
12838            _depth: fidl::encoding::Depth,
12839        ) -> fidl::Result<()> {
12840            decoder.debug_check_bounds::<Self>(offset);
12841            // Verify that padding bytes are zero.
12842            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
12843            fidl::decode!(
12844                fidl::encoding::Optional<
12845                    fidl::encoding::HandleType<
12846                        fidl::EventPair,
12847                        { fidl::ObjectType::EVENTPAIR.into_raw() },
12848                        2147483648,
12849                    >,
12850                >,
12851                fidl::encoding::DefaultFuchsiaResourceDialect,
12852                &mut self.token,
12853                decoder,
12854                offset + 4,
12855                _depth
12856            )?;
12857            fidl::decode!(fidl::encoding::Vector<u8, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.info, decoder, offset + 8, _depth)?;
12858            Ok(())
12859        }
12860    }
12861
12862    impl fidl::encoding::ResourceTypeMarker for VirtioInputStartRequest {
12863        type Borrowed<'a> = &'a mut Self;
12864        fn take_or_borrow<'a>(
12865            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12866        ) -> Self::Borrowed<'a> {
12867            value
12868        }
12869    }
12870
12871    unsafe impl fidl::encoding::TypeMarker for VirtioInputStartRequest {
12872        type Owned = Self;
12873
12874        #[inline(always)]
12875        fn inline_align(_context: fidl::encoding::Context) -> usize {
12876            8
12877        }
12878
12879        #[inline(always)]
12880        fn inline_size(_context: fidl::encoding::Context) -> usize {
12881            48
12882        }
12883    }
12884
12885    unsafe impl
12886        fidl::encoding::Encode<
12887            VirtioInputStartRequest,
12888            fidl::encoding::DefaultFuchsiaResourceDialect,
12889        > for &mut VirtioInputStartRequest
12890    {
12891        #[inline]
12892        unsafe fn encode(
12893            self,
12894            encoder: &mut fidl::encoding::Encoder<
12895                '_,
12896                fidl::encoding::DefaultFuchsiaResourceDialect,
12897            >,
12898            offset: usize,
12899            _depth: fidl::encoding::Depth,
12900        ) -> fidl::Result<()> {
12901            encoder.debug_check_bounds::<VirtioInputStartRequest>(offset);
12902            // Delegate to tuple encoding.
12903            fidl::encoding::Encode::<
12904                VirtioInputStartRequest,
12905                fidl::encoding::DefaultFuchsiaResourceDialect,
12906            >::encode(
12907                (
12908                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12909                        &mut self.start_info,
12910                    ),
12911                    <InputType as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12912                        &mut self.input_type,
12913                    ),
12914                ),
12915                encoder,
12916                offset,
12917                _depth,
12918            )
12919        }
12920    }
12921    unsafe impl<
12922            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
12923            T1: fidl::encoding::Encode<InputType, fidl::encoding::DefaultFuchsiaResourceDialect>,
12924        >
12925        fidl::encoding::Encode<
12926            VirtioInputStartRequest,
12927            fidl::encoding::DefaultFuchsiaResourceDialect,
12928        > for (T0, T1)
12929    {
12930        #[inline]
12931        unsafe fn encode(
12932            self,
12933            encoder: &mut fidl::encoding::Encoder<
12934                '_,
12935                fidl::encoding::DefaultFuchsiaResourceDialect,
12936            >,
12937            offset: usize,
12938            depth: fidl::encoding::Depth,
12939        ) -> fidl::Result<()> {
12940            encoder.debug_check_bounds::<VirtioInputStartRequest>(offset);
12941            // Zero out padding regions. There's no need to apply masks
12942            // because the unmasked parts will be overwritten by fields.
12943            // Write the fields.
12944            self.0.encode(encoder, offset + 0, depth)?;
12945            self.1.encode(encoder, offset + 32, depth)?;
12946            Ok(())
12947        }
12948    }
12949
12950    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12951        for VirtioInputStartRequest
12952    {
12953        #[inline(always)]
12954        fn new_empty() -> Self {
12955            Self {
12956                start_info: fidl::new_empty!(
12957                    StartInfo,
12958                    fidl::encoding::DefaultFuchsiaResourceDialect
12959                ),
12960                input_type: fidl::new_empty!(
12961                    InputType,
12962                    fidl::encoding::DefaultFuchsiaResourceDialect
12963                ),
12964            }
12965        }
12966
12967        #[inline]
12968        unsafe fn decode(
12969            &mut self,
12970            decoder: &mut fidl::encoding::Decoder<
12971                '_,
12972                fidl::encoding::DefaultFuchsiaResourceDialect,
12973            >,
12974            offset: usize,
12975            _depth: fidl::encoding::Depth,
12976        ) -> fidl::Result<()> {
12977            decoder.debug_check_bounds::<Self>(offset);
12978            // Verify that padding bytes are zero.
12979            fidl::decode!(
12980                StartInfo,
12981                fidl::encoding::DefaultFuchsiaResourceDialect,
12982                &mut self.start_info,
12983                decoder,
12984                offset + 0,
12985                _depth
12986            )?;
12987            fidl::decode!(
12988                InputType,
12989                fidl::encoding::DefaultFuchsiaResourceDialect,
12990                &mut self.input_type,
12991                decoder,
12992                offset + 32,
12993                _depth
12994            )?;
12995            Ok(())
12996        }
12997    }
12998
12999    impl fidl::encoding::ResourceTypeMarker for VirtioMagmaStartRequest {
13000        type Borrowed<'a> = &'a mut Self;
13001        fn take_or_borrow<'a>(
13002            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13003        ) -> Self::Borrowed<'a> {
13004            value
13005        }
13006    }
13007
13008    unsafe impl fidl::encoding::TypeMarker for VirtioMagmaStartRequest {
13009        type Owned = Self;
13010
13011        #[inline(always)]
13012        fn inline_align(_context: fidl::encoding::Context) -> usize {
13013            8
13014        }
13015
13016        #[inline(always)]
13017        fn inline_size(_context: fidl::encoding::Context) -> usize {
13018            40
13019        }
13020    }
13021
13022    unsafe impl
13023        fidl::encoding::Encode<
13024            VirtioMagmaStartRequest,
13025            fidl::encoding::DefaultFuchsiaResourceDialect,
13026        > for &mut VirtioMagmaStartRequest
13027    {
13028        #[inline]
13029        unsafe fn encode(
13030            self,
13031            encoder: &mut fidl::encoding::Encoder<
13032                '_,
13033                fidl::encoding::DefaultFuchsiaResourceDialect,
13034            >,
13035            offset: usize,
13036            _depth: fidl::encoding::Depth,
13037        ) -> fidl::Result<()> {
13038            encoder.debug_check_bounds::<VirtioMagmaStartRequest>(offset);
13039            // Delegate to tuple encoding.
13040            fidl::encoding::Encode::<
13041                VirtioMagmaStartRequest,
13042                fidl::encoding::DefaultFuchsiaResourceDialect,
13043            >::encode(
13044                (
13045                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13046                        &mut self.start_info,
13047                    ),
13048                    <fidl::encoding::HandleType<
13049                        fidl::Vmar,
13050                        { fidl::ObjectType::VMAR.into_raw() },
13051                        2147483648,
13052                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13053                        &mut self.vmar
13054                    ),
13055                    <fidl::encoding::Optional<
13056                        fidl::encoding::Endpoint<
13057                            fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>,
13058                        >,
13059                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13060                        &mut self.wayland_importer,
13061                    ),
13062                ),
13063                encoder,
13064                offset,
13065                _depth,
13066            )
13067        }
13068    }
13069    unsafe impl<
13070            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13071            T1: fidl::encoding::Encode<
13072                fidl::encoding::HandleType<
13073                    fidl::Vmar,
13074                    { fidl::ObjectType::VMAR.into_raw() },
13075                    2147483648,
13076                >,
13077                fidl::encoding::DefaultFuchsiaResourceDialect,
13078            >,
13079            T2: fidl::encoding::Encode<
13080                fidl::encoding::Optional<
13081                    fidl::encoding::Endpoint<
13082                        fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>,
13083                    >,
13084                >,
13085                fidl::encoding::DefaultFuchsiaResourceDialect,
13086            >,
13087        >
13088        fidl::encoding::Encode<
13089            VirtioMagmaStartRequest,
13090            fidl::encoding::DefaultFuchsiaResourceDialect,
13091        > for (T0, T1, T2)
13092    {
13093        #[inline]
13094        unsafe fn encode(
13095            self,
13096            encoder: &mut fidl::encoding::Encoder<
13097                '_,
13098                fidl::encoding::DefaultFuchsiaResourceDialect,
13099            >,
13100            offset: usize,
13101            depth: fidl::encoding::Depth,
13102        ) -> fidl::Result<()> {
13103            encoder.debug_check_bounds::<VirtioMagmaStartRequest>(offset);
13104            // Zero out padding regions. There's no need to apply masks
13105            // because the unmasked parts will be overwritten by fields.
13106            // Write the fields.
13107            self.0.encode(encoder, offset + 0, depth)?;
13108            self.1.encode(encoder, offset + 32, depth)?;
13109            self.2.encode(encoder, offset + 36, depth)?;
13110            Ok(())
13111        }
13112    }
13113
13114    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13115        for VirtioMagmaStartRequest
13116    {
13117        #[inline(always)]
13118        fn new_empty() -> Self {
13119            Self {
13120                start_info: fidl::new_empty!(
13121                    StartInfo,
13122                    fidl::encoding::DefaultFuchsiaResourceDialect
13123                ),
13124                vmar: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13125                wayland_importer: fidl::new_empty!(
13126                    fidl::encoding::Optional<
13127                        fidl::encoding::Endpoint<
13128                            fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>,
13129                        >,
13130                    >,
13131                    fidl::encoding::DefaultFuchsiaResourceDialect
13132                ),
13133            }
13134        }
13135
13136        #[inline]
13137        unsafe fn decode(
13138            &mut self,
13139            decoder: &mut fidl::encoding::Decoder<
13140                '_,
13141                fidl::encoding::DefaultFuchsiaResourceDialect,
13142            >,
13143            offset: usize,
13144            _depth: fidl::encoding::Depth,
13145        ) -> fidl::Result<()> {
13146            decoder.debug_check_bounds::<Self>(offset);
13147            // Verify that padding bytes are zero.
13148            fidl::decode!(
13149                StartInfo,
13150                fidl::encoding::DefaultFuchsiaResourceDialect,
13151                &mut self.start_info,
13152                decoder,
13153                offset + 0,
13154                _depth
13155            )?;
13156            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar, decoder, offset + 32, _depth)?;
13157            fidl::decode!(
13158                fidl::encoding::Optional<
13159                    fidl::encoding::Endpoint<
13160                        fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>,
13161                    >,
13162                >,
13163                fidl::encoding::DefaultFuchsiaResourceDialect,
13164                &mut self.wayland_importer,
13165                decoder,
13166                offset + 36,
13167                _depth
13168            )?;
13169            Ok(())
13170        }
13171    }
13172
13173    impl fidl::encoding::ResourceTypeMarker for VirtioMemStartRequest {
13174        type Borrowed<'a> = &'a mut Self;
13175        fn take_or_borrow<'a>(
13176            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13177        ) -> Self::Borrowed<'a> {
13178            value
13179        }
13180    }
13181
13182    unsafe impl fidl::encoding::TypeMarker for VirtioMemStartRequest {
13183        type Owned = Self;
13184
13185        #[inline(always)]
13186        fn inline_align(_context: fidl::encoding::Context) -> usize {
13187            8
13188        }
13189
13190        #[inline(always)]
13191        fn inline_size(_context: fidl::encoding::Context) -> usize {
13192            56
13193        }
13194    }
13195
13196    unsafe impl
13197        fidl::encoding::Encode<VirtioMemStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13198        for &mut VirtioMemStartRequest
13199    {
13200        #[inline]
13201        unsafe fn encode(
13202            self,
13203            encoder: &mut fidl::encoding::Encoder<
13204                '_,
13205                fidl::encoding::DefaultFuchsiaResourceDialect,
13206            >,
13207            offset: usize,
13208            _depth: fidl::encoding::Depth,
13209        ) -> fidl::Result<()> {
13210            encoder.debug_check_bounds::<VirtioMemStartRequest>(offset);
13211            // Delegate to tuple encoding.
13212            fidl::encoding::Encode::<
13213                VirtioMemStartRequest,
13214                fidl::encoding::DefaultFuchsiaResourceDialect,
13215            >::encode(
13216                (
13217                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13218                        &mut self.start_info,
13219                    ),
13220                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.region_addr),
13221                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.plugged_block_size),
13222                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.region_size),
13223                ),
13224                encoder,
13225                offset,
13226                _depth,
13227            )
13228        }
13229    }
13230    unsafe impl<
13231            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13232            T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
13233            T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
13234            T3: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
13235        >
13236        fidl::encoding::Encode<VirtioMemStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13237        for (T0, T1, T2, T3)
13238    {
13239        #[inline]
13240        unsafe fn encode(
13241            self,
13242            encoder: &mut fidl::encoding::Encoder<
13243                '_,
13244                fidl::encoding::DefaultFuchsiaResourceDialect,
13245            >,
13246            offset: usize,
13247            depth: fidl::encoding::Depth,
13248        ) -> fidl::Result<()> {
13249            encoder.debug_check_bounds::<VirtioMemStartRequest>(offset);
13250            // Zero out padding regions. There's no need to apply masks
13251            // because the unmasked parts will be overwritten by fields.
13252            // Write the fields.
13253            self.0.encode(encoder, offset + 0, depth)?;
13254            self.1.encode(encoder, offset + 32, depth)?;
13255            self.2.encode(encoder, offset + 40, depth)?;
13256            self.3.encode(encoder, offset + 48, depth)?;
13257            Ok(())
13258        }
13259    }
13260
13261    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13262        for VirtioMemStartRequest
13263    {
13264        #[inline(always)]
13265        fn new_empty() -> Self {
13266            Self {
13267                start_info: fidl::new_empty!(
13268                    StartInfo,
13269                    fidl::encoding::DefaultFuchsiaResourceDialect
13270                ),
13271                region_addr: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
13272                plugged_block_size: fidl::new_empty!(
13273                    u64,
13274                    fidl::encoding::DefaultFuchsiaResourceDialect
13275                ),
13276                region_size: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
13277            }
13278        }
13279
13280        #[inline]
13281        unsafe fn decode(
13282            &mut self,
13283            decoder: &mut fidl::encoding::Decoder<
13284                '_,
13285                fidl::encoding::DefaultFuchsiaResourceDialect,
13286            >,
13287            offset: usize,
13288            _depth: fidl::encoding::Depth,
13289        ) -> fidl::Result<()> {
13290            decoder.debug_check_bounds::<Self>(offset);
13291            // Verify that padding bytes are zero.
13292            fidl::decode!(
13293                StartInfo,
13294                fidl::encoding::DefaultFuchsiaResourceDialect,
13295                &mut self.start_info,
13296                decoder,
13297                offset + 0,
13298                _depth
13299            )?;
13300            fidl::decode!(
13301                u64,
13302                fidl::encoding::DefaultFuchsiaResourceDialect,
13303                &mut self.region_addr,
13304                decoder,
13305                offset + 32,
13306                _depth
13307            )?;
13308            fidl::decode!(
13309                u64,
13310                fidl::encoding::DefaultFuchsiaResourceDialect,
13311                &mut self.plugged_block_size,
13312                decoder,
13313                offset + 40,
13314                _depth
13315            )?;
13316            fidl::decode!(
13317                u64,
13318                fidl::encoding::DefaultFuchsiaResourceDialect,
13319                &mut self.region_size,
13320                decoder,
13321                offset + 48,
13322                _depth
13323            )?;
13324            Ok(())
13325        }
13326    }
13327
13328    impl fidl::encoding::ResourceTypeMarker for VirtioNetStartRequest {
13329        type Borrowed<'a> = &'a mut Self;
13330        fn take_or_borrow<'a>(
13331            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13332        ) -> Self::Borrowed<'a> {
13333            value
13334        }
13335    }
13336
13337    unsafe impl fidl::encoding::TypeMarker for VirtioNetStartRequest {
13338        type Owned = Self;
13339
13340        #[inline(always)]
13341        fn inline_align(_context: fidl::encoding::Context) -> usize {
13342            8
13343        }
13344
13345        #[inline(always)]
13346        fn inline_size(_context: fidl::encoding::Context) -> usize {
13347            40
13348        }
13349    }
13350
13351    unsafe impl
13352        fidl::encoding::Encode<VirtioNetStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13353        for &mut VirtioNetStartRequest
13354    {
13355        #[inline]
13356        unsafe fn encode(
13357            self,
13358            encoder: &mut fidl::encoding::Encoder<
13359                '_,
13360                fidl::encoding::DefaultFuchsiaResourceDialect,
13361            >,
13362            offset: usize,
13363            _depth: fidl::encoding::Depth,
13364        ) -> fidl::Result<()> {
13365            encoder.debug_check_bounds::<VirtioNetStartRequest>(offset);
13366            // Delegate to tuple encoding.
13367            fidl::encoding::Encode::<
13368                VirtioNetStartRequest,
13369                fidl::encoding::DefaultFuchsiaResourceDialect,
13370            >::encode(
13371                (
13372                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13373                        &mut self.start_info,
13374                    ),
13375                    <fidl_fuchsia_net::MacAddress as fidl::encoding::ValueTypeMarker>::borrow(
13376                        &self.mac_address,
13377                    ),
13378                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_bridge),
13379                ),
13380                encoder,
13381                offset,
13382                _depth,
13383            )
13384        }
13385    }
13386    unsafe impl<
13387            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13388            T1: fidl::encoding::Encode<
13389                fidl_fuchsia_net::MacAddress,
13390                fidl::encoding::DefaultFuchsiaResourceDialect,
13391            >,
13392            T2: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
13393        >
13394        fidl::encoding::Encode<VirtioNetStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13395        for (T0, T1, T2)
13396    {
13397        #[inline]
13398        unsafe fn encode(
13399            self,
13400            encoder: &mut fidl::encoding::Encoder<
13401                '_,
13402                fidl::encoding::DefaultFuchsiaResourceDialect,
13403            >,
13404            offset: usize,
13405            depth: fidl::encoding::Depth,
13406        ) -> fidl::Result<()> {
13407            encoder.debug_check_bounds::<VirtioNetStartRequest>(offset);
13408            // Zero out padding regions. There's no need to apply masks
13409            // because the unmasked parts will be overwritten by fields.
13410            unsafe {
13411                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
13412                (ptr as *mut u64).write_unaligned(0);
13413            }
13414            // Write the fields.
13415            self.0.encode(encoder, offset + 0, depth)?;
13416            self.1.encode(encoder, offset + 32, depth)?;
13417            self.2.encode(encoder, offset + 38, depth)?;
13418            Ok(())
13419        }
13420    }
13421
13422    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13423        for VirtioNetStartRequest
13424    {
13425        #[inline(always)]
13426        fn new_empty() -> Self {
13427            Self {
13428                start_info: fidl::new_empty!(
13429                    StartInfo,
13430                    fidl::encoding::DefaultFuchsiaResourceDialect
13431                ),
13432                mac_address: fidl::new_empty!(
13433                    fidl_fuchsia_net::MacAddress,
13434                    fidl::encoding::DefaultFuchsiaResourceDialect
13435                ),
13436                enable_bridge: fidl::new_empty!(
13437                    bool,
13438                    fidl::encoding::DefaultFuchsiaResourceDialect
13439                ),
13440            }
13441        }
13442
13443        #[inline]
13444        unsafe fn decode(
13445            &mut self,
13446            decoder: &mut fidl::encoding::Decoder<
13447                '_,
13448                fidl::encoding::DefaultFuchsiaResourceDialect,
13449            >,
13450            offset: usize,
13451            _depth: fidl::encoding::Depth,
13452        ) -> fidl::Result<()> {
13453            decoder.debug_check_bounds::<Self>(offset);
13454            // Verify that padding bytes are zero.
13455            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
13456            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13457            let mask = 0xff00000000000000u64;
13458            let maskedval = padval & mask;
13459            if maskedval != 0 {
13460                return Err(fidl::Error::NonZeroPadding {
13461                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
13462                });
13463            }
13464            fidl::decode!(
13465                StartInfo,
13466                fidl::encoding::DefaultFuchsiaResourceDialect,
13467                &mut self.start_info,
13468                decoder,
13469                offset + 0,
13470                _depth
13471            )?;
13472            fidl::decode!(
13473                fidl_fuchsia_net::MacAddress,
13474                fidl::encoding::DefaultFuchsiaResourceDialect,
13475                &mut self.mac_address,
13476                decoder,
13477                offset + 32,
13478                _depth
13479            )?;
13480            fidl::decode!(
13481                bool,
13482                fidl::encoding::DefaultFuchsiaResourceDialect,
13483                &mut self.enable_bridge,
13484                decoder,
13485                offset + 38,
13486                _depth
13487            )?;
13488            Ok(())
13489        }
13490    }
13491
13492    impl fidl::encoding::ResourceTypeMarker for VirtioRngStartRequest {
13493        type Borrowed<'a> = &'a mut Self;
13494        fn take_or_borrow<'a>(
13495            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13496        ) -> Self::Borrowed<'a> {
13497            value
13498        }
13499    }
13500
13501    unsafe impl fidl::encoding::TypeMarker for VirtioRngStartRequest {
13502        type Owned = Self;
13503
13504        #[inline(always)]
13505        fn inline_align(_context: fidl::encoding::Context) -> usize {
13506            8
13507        }
13508
13509        #[inline(always)]
13510        fn inline_size(_context: fidl::encoding::Context) -> usize {
13511            32
13512        }
13513    }
13514
13515    unsafe impl
13516        fidl::encoding::Encode<VirtioRngStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13517        for &mut VirtioRngStartRequest
13518    {
13519        #[inline]
13520        unsafe fn encode(
13521            self,
13522            encoder: &mut fidl::encoding::Encoder<
13523                '_,
13524                fidl::encoding::DefaultFuchsiaResourceDialect,
13525            >,
13526            offset: usize,
13527            _depth: fidl::encoding::Depth,
13528        ) -> fidl::Result<()> {
13529            encoder.debug_check_bounds::<VirtioRngStartRequest>(offset);
13530            // Delegate to tuple encoding.
13531            fidl::encoding::Encode::<
13532                VirtioRngStartRequest,
13533                fidl::encoding::DefaultFuchsiaResourceDialect,
13534            >::encode(
13535                (<StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13536                    &mut self.start_info,
13537                ),),
13538                encoder,
13539                offset,
13540                _depth,
13541            )
13542        }
13543    }
13544    unsafe impl<T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>>
13545        fidl::encoding::Encode<VirtioRngStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13546        for (T0,)
13547    {
13548        #[inline]
13549        unsafe fn encode(
13550            self,
13551            encoder: &mut fidl::encoding::Encoder<
13552                '_,
13553                fidl::encoding::DefaultFuchsiaResourceDialect,
13554            >,
13555            offset: usize,
13556            depth: fidl::encoding::Depth,
13557        ) -> fidl::Result<()> {
13558            encoder.debug_check_bounds::<VirtioRngStartRequest>(offset);
13559            // Zero out padding regions. There's no need to apply masks
13560            // because the unmasked parts will be overwritten by fields.
13561            // Write the fields.
13562            self.0.encode(encoder, offset + 0, depth)?;
13563            Ok(())
13564        }
13565    }
13566
13567    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13568        for VirtioRngStartRequest
13569    {
13570        #[inline(always)]
13571        fn new_empty() -> Self {
13572            Self {
13573                start_info: fidl::new_empty!(
13574                    StartInfo,
13575                    fidl::encoding::DefaultFuchsiaResourceDialect
13576                ),
13577            }
13578        }
13579
13580        #[inline]
13581        unsafe fn decode(
13582            &mut self,
13583            decoder: &mut fidl::encoding::Decoder<
13584                '_,
13585                fidl::encoding::DefaultFuchsiaResourceDialect,
13586            >,
13587            offset: usize,
13588            _depth: fidl::encoding::Depth,
13589        ) -> fidl::Result<()> {
13590            decoder.debug_check_bounds::<Self>(offset);
13591            // Verify that padding bytes are zero.
13592            fidl::decode!(
13593                StartInfo,
13594                fidl::encoding::DefaultFuchsiaResourceDialect,
13595                &mut self.start_info,
13596                decoder,
13597                offset + 0,
13598                _depth
13599            )?;
13600            Ok(())
13601        }
13602    }
13603
13604    impl fidl::encoding::ResourceTypeMarker for VirtioSoundStartRequest {
13605        type Borrowed<'a> = &'a mut Self;
13606        fn take_or_borrow<'a>(
13607            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13608        ) -> Self::Borrowed<'a> {
13609            value
13610        }
13611    }
13612
13613    unsafe impl fidl::encoding::TypeMarker for VirtioSoundStartRequest {
13614        type Owned = Self;
13615
13616        #[inline(always)]
13617        fn inline_align(_context: fidl::encoding::Context) -> usize {
13618            8
13619        }
13620
13621        #[inline(always)]
13622        fn inline_size(_context: fidl::encoding::Context) -> usize {
13623            40
13624        }
13625    }
13626
13627    unsafe impl
13628        fidl::encoding::Encode<
13629            VirtioSoundStartRequest,
13630            fidl::encoding::DefaultFuchsiaResourceDialect,
13631        > for &mut VirtioSoundStartRequest
13632    {
13633        #[inline]
13634        unsafe fn encode(
13635            self,
13636            encoder: &mut fidl::encoding::Encoder<
13637                '_,
13638                fidl::encoding::DefaultFuchsiaResourceDialect,
13639            >,
13640            offset: usize,
13641            _depth: fidl::encoding::Depth,
13642        ) -> fidl::Result<()> {
13643            encoder.debug_check_bounds::<VirtioSoundStartRequest>(offset);
13644            // Delegate to tuple encoding.
13645            fidl::encoding::Encode::<
13646                VirtioSoundStartRequest,
13647                fidl::encoding::DefaultFuchsiaResourceDialect,
13648            >::encode(
13649                (
13650                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13651                        &mut self.start_info,
13652                    ),
13653                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_input),
13654                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_verbose_logging),
13655                ),
13656                encoder,
13657                offset,
13658                _depth,
13659            )
13660        }
13661    }
13662    unsafe impl<
13663            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13664            T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
13665            T2: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
13666        >
13667        fidl::encoding::Encode<
13668            VirtioSoundStartRequest,
13669            fidl::encoding::DefaultFuchsiaResourceDialect,
13670        > for (T0, T1, T2)
13671    {
13672        #[inline]
13673        unsafe fn encode(
13674            self,
13675            encoder: &mut fidl::encoding::Encoder<
13676                '_,
13677                fidl::encoding::DefaultFuchsiaResourceDialect,
13678            >,
13679            offset: usize,
13680            depth: fidl::encoding::Depth,
13681        ) -> fidl::Result<()> {
13682            encoder.debug_check_bounds::<VirtioSoundStartRequest>(offset);
13683            // Zero out padding regions. There's no need to apply masks
13684            // because the unmasked parts will be overwritten by fields.
13685            unsafe {
13686                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
13687                (ptr as *mut u64).write_unaligned(0);
13688            }
13689            // Write the fields.
13690            self.0.encode(encoder, offset + 0, depth)?;
13691            self.1.encode(encoder, offset + 32, depth)?;
13692            self.2.encode(encoder, offset + 33, depth)?;
13693            Ok(())
13694        }
13695    }
13696
13697    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13698        for VirtioSoundStartRequest
13699    {
13700        #[inline(always)]
13701        fn new_empty() -> Self {
13702            Self {
13703                start_info: fidl::new_empty!(
13704                    StartInfo,
13705                    fidl::encoding::DefaultFuchsiaResourceDialect
13706                ),
13707                enable_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
13708                enable_verbose_logging: fidl::new_empty!(
13709                    bool,
13710                    fidl::encoding::DefaultFuchsiaResourceDialect
13711                ),
13712            }
13713        }
13714
13715        #[inline]
13716        unsafe fn decode(
13717            &mut self,
13718            decoder: &mut fidl::encoding::Decoder<
13719                '_,
13720                fidl::encoding::DefaultFuchsiaResourceDialect,
13721            >,
13722            offset: usize,
13723            _depth: fidl::encoding::Depth,
13724        ) -> fidl::Result<()> {
13725            decoder.debug_check_bounds::<Self>(offset);
13726            // Verify that padding bytes are zero.
13727            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
13728            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13729            let mask = 0xffffffffffff0000u64;
13730            let maskedval = padval & mask;
13731            if maskedval != 0 {
13732                return Err(fidl::Error::NonZeroPadding {
13733                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
13734                });
13735            }
13736            fidl::decode!(
13737                StartInfo,
13738                fidl::encoding::DefaultFuchsiaResourceDialect,
13739                &mut self.start_info,
13740                decoder,
13741                offset + 0,
13742                _depth
13743            )?;
13744            fidl::decode!(
13745                bool,
13746                fidl::encoding::DefaultFuchsiaResourceDialect,
13747                &mut self.enable_input,
13748                decoder,
13749                offset + 32,
13750                _depth
13751            )?;
13752            fidl::decode!(
13753                bool,
13754                fidl::encoding::DefaultFuchsiaResourceDialect,
13755                &mut self.enable_verbose_logging,
13756                decoder,
13757                offset + 33,
13758                _depth
13759            )?;
13760            Ok(())
13761        }
13762    }
13763
13764    impl fidl::encoding::ResourceTypeMarker for VirtioVsockStartRequest {
13765        type Borrowed<'a> = &'a mut Self;
13766        fn take_or_borrow<'a>(
13767            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13768        ) -> Self::Borrowed<'a> {
13769            value
13770        }
13771    }
13772
13773    unsafe impl fidl::encoding::TypeMarker for VirtioVsockStartRequest {
13774        type Owned = Self;
13775
13776        #[inline(always)]
13777        fn inline_align(_context: fidl::encoding::Context) -> usize {
13778            8
13779        }
13780
13781        #[inline(always)]
13782        fn inline_size(_context: fidl::encoding::Context) -> usize {
13783            56
13784        }
13785    }
13786
13787    unsafe impl
13788        fidl::encoding::Encode<
13789            VirtioVsockStartRequest,
13790            fidl::encoding::DefaultFuchsiaResourceDialect,
13791        > for &mut VirtioVsockStartRequest
13792    {
13793        #[inline]
13794        unsafe fn encode(
13795            self,
13796            encoder: &mut fidl::encoding::Encoder<
13797                '_,
13798                fidl::encoding::DefaultFuchsiaResourceDialect,
13799            >,
13800            offset: usize,
13801            _depth: fidl::encoding::Depth,
13802        ) -> fidl::Result<()> {
13803            encoder.debug_check_bounds::<VirtioVsockStartRequest>(offset);
13804            // Delegate to tuple encoding.
13805            fidl::encoding::Encode::<VirtioVsockStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
13806                (
13807                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.start_info),
13808                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_cid),
13809                    <fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listeners),
13810                ),
13811                encoder, offset, _depth
13812            )
13813        }
13814    }
13815    unsafe impl<
13816            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
13817            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13818            T2: fidl::encoding::Encode<
13819                fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
13820                fidl::encoding::DefaultFuchsiaResourceDialect,
13821            >,
13822        >
13823        fidl::encoding::Encode<
13824            VirtioVsockStartRequest,
13825            fidl::encoding::DefaultFuchsiaResourceDialect,
13826        > for (T0, T1, T2)
13827    {
13828        #[inline]
13829        unsafe fn encode(
13830            self,
13831            encoder: &mut fidl::encoding::Encoder<
13832                '_,
13833                fidl::encoding::DefaultFuchsiaResourceDialect,
13834            >,
13835            offset: usize,
13836            depth: fidl::encoding::Depth,
13837        ) -> fidl::Result<()> {
13838            encoder.debug_check_bounds::<VirtioVsockStartRequest>(offset);
13839            // Zero out padding regions. There's no need to apply masks
13840            // because the unmasked parts will be overwritten by fields.
13841            unsafe {
13842                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
13843                (ptr as *mut u64).write_unaligned(0);
13844            }
13845            // Write the fields.
13846            self.0.encode(encoder, offset + 0, depth)?;
13847            self.1.encode(encoder, offset + 32, depth)?;
13848            self.2.encode(encoder, offset + 40, depth)?;
13849            Ok(())
13850        }
13851    }
13852
13853    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13854        for VirtioVsockStartRequest
13855    {
13856        #[inline(always)]
13857        fn new_empty() -> Self {
13858            Self {
13859                start_info: fidl::new_empty!(
13860                    StartInfo,
13861                    fidl::encoding::DefaultFuchsiaResourceDialect
13862                ),
13863                guest_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
13864                listeners: fidl::new_empty!(
13865                    fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
13866                    fidl::encoding::DefaultFuchsiaResourceDialect
13867                ),
13868            }
13869        }
13870
13871        #[inline]
13872        unsafe fn decode(
13873            &mut self,
13874            decoder: &mut fidl::encoding::Decoder<
13875                '_,
13876                fidl::encoding::DefaultFuchsiaResourceDialect,
13877            >,
13878            offset: usize,
13879            _depth: fidl::encoding::Depth,
13880        ) -> fidl::Result<()> {
13881            decoder.debug_check_bounds::<Self>(offset);
13882            // Verify that padding bytes are zero.
13883            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
13884            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13885            let mask = 0xffffffff00000000u64;
13886            let maskedval = padval & mask;
13887            if maskedval != 0 {
13888                return Err(fidl::Error::NonZeroPadding {
13889                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
13890                });
13891            }
13892            fidl::decode!(
13893                StartInfo,
13894                fidl::encoding::DefaultFuchsiaResourceDialect,
13895                &mut self.start_info,
13896                decoder,
13897                offset + 0,
13898                _depth
13899            )?;
13900            fidl::decode!(
13901                u32,
13902                fidl::encoding::DefaultFuchsiaResourceDialect,
13903                &mut self.guest_cid,
13904                decoder,
13905                offset + 32,
13906                _depth
13907            )?;
13908            fidl::decode!(
13909                fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
13910                fidl::encoding::DefaultFuchsiaResourceDialect,
13911                &mut self.listeners,
13912                decoder,
13913                offset + 40,
13914                _depth
13915            )?;
13916            Ok(())
13917        }
13918    }
13919
13920    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandGetImporterRequest {
13921        type Borrowed<'a> = &'a mut Self;
13922        fn take_or_borrow<'a>(
13923            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13924        ) -> Self::Borrowed<'a> {
13925            value
13926        }
13927    }
13928
13929    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandGetImporterRequest {
13930        type Owned = Self;
13931
13932        #[inline(always)]
13933        fn inline_align(_context: fidl::encoding::Context) -> usize {
13934            4
13935        }
13936
13937        #[inline(always)]
13938        fn inline_size(_context: fidl::encoding::Context) -> usize {
13939            4
13940        }
13941    }
13942
13943    unsafe impl
13944        fidl::encoding::Encode<
13945            VirtioWaylandGetImporterRequest,
13946            fidl::encoding::DefaultFuchsiaResourceDialect,
13947        > for &mut VirtioWaylandGetImporterRequest
13948    {
13949        #[inline]
13950        unsafe fn encode(
13951            self,
13952            encoder: &mut fidl::encoding::Encoder<
13953                '_,
13954                fidl::encoding::DefaultFuchsiaResourceDialect,
13955            >,
13956            offset: usize,
13957            _depth: fidl::encoding::Depth,
13958        ) -> fidl::Result<()> {
13959            encoder.debug_check_bounds::<VirtioWaylandGetImporterRequest>(offset);
13960            // Delegate to tuple encoding.
13961            fidl::encoding::Encode::<
13962                VirtioWaylandGetImporterRequest,
13963                fidl::encoding::DefaultFuchsiaResourceDialect,
13964            >::encode(
13965                (
13966                    <fidl::encoding::Endpoint<
13967                        fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
13968                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13969                        &mut self.importer
13970                    ),
13971                ),
13972                encoder,
13973                offset,
13974                _depth,
13975            )
13976        }
13977    }
13978    unsafe impl<
13979            T0: fidl::encoding::Encode<
13980                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>>,
13981                fidl::encoding::DefaultFuchsiaResourceDialect,
13982            >,
13983        >
13984        fidl::encoding::Encode<
13985            VirtioWaylandGetImporterRequest,
13986            fidl::encoding::DefaultFuchsiaResourceDialect,
13987        > for (T0,)
13988    {
13989        #[inline]
13990        unsafe fn encode(
13991            self,
13992            encoder: &mut fidl::encoding::Encoder<
13993                '_,
13994                fidl::encoding::DefaultFuchsiaResourceDialect,
13995            >,
13996            offset: usize,
13997            depth: fidl::encoding::Depth,
13998        ) -> fidl::Result<()> {
13999            encoder.debug_check_bounds::<VirtioWaylandGetImporterRequest>(offset);
14000            // Zero out padding regions. There's no need to apply masks
14001            // because the unmasked parts will be overwritten by fields.
14002            // Write the fields.
14003            self.0.encode(encoder, offset + 0, depth)?;
14004            Ok(())
14005        }
14006    }
14007
14008    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14009        for VirtioWaylandGetImporterRequest
14010    {
14011        #[inline(always)]
14012        fn new_empty() -> Self {
14013            Self {
14014                importer: fidl::new_empty!(
14015                    fidl::encoding::Endpoint<
14016                        fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
14017                    >,
14018                    fidl::encoding::DefaultFuchsiaResourceDialect
14019                ),
14020            }
14021        }
14022
14023        #[inline]
14024        unsafe fn decode(
14025            &mut self,
14026            decoder: &mut fidl::encoding::Decoder<
14027                '_,
14028                fidl::encoding::DefaultFuchsiaResourceDialect,
14029            >,
14030            offset: usize,
14031            _depth: fidl::encoding::Depth,
14032        ) -> fidl::Result<()> {
14033            decoder.debug_check_bounds::<Self>(offset);
14034            // Verify that padding bytes are zero.
14035            fidl::decode!(
14036                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>>,
14037                fidl::encoding::DefaultFuchsiaResourceDialect,
14038                &mut self.importer,
14039                decoder,
14040                offset + 0,
14041                _depth
14042            )?;
14043            Ok(())
14044        }
14045    }
14046
14047    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandImporterExportImageResponse {
14048        type Borrowed<'a> = &'a mut Self;
14049        fn take_or_borrow<'a>(
14050            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14051        ) -> Self::Borrowed<'a> {
14052            value
14053        }
14054    }
14055
14056    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandImporterExportImageResponse {
14057        type Owned = Self;
14058
14059        #[inline(always)]
14060        fn inline_align(_context: fidl::encoding::Context) -> usize {
14061            8
14062        }
14063
14064        #[inline(always)]
14065        fn inline_size(_context: fidl::encoding::Context) -> usize {
14066            16
14067        }
14068    }
14069
14070    unsafe impl
14071        fidl::encoding::Encode<
14072            VirtioWaylandImporterExportImageResponse,
14073            fidl::encoding::DefaultFuchsiaResourceDialect,
14074        > for &mut VirtioWaylandImporterExportImageResponse
14075    {
14076        #[inline]
14077        unsafe fn encode(
14078            self,
14079            encoder: &mut fidl::encoding::Encoder<
14080                '_,
14081                fidl::encoding::DefaultFuchsiaResourceDialect,
14082            >,
14083            offset: usize,
14084            _depth: fidl::encoding::Depth,
14085        ) -> fidl::Result<()> {
14086            encoder.debug_check_bounds::<VirtioWaylandImporterExportImageResponse>(offset);
14087            // Delegate to tuple encoding.
14088            fidl::encoding::Encode::<VirtioWaylandImporterExportImageResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14089                (
14090                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
14091                    <fidl::encoding::Boxed<VirtioImage> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.image),
14092                ),
14093                encoder, offset, _depth
14094            )
14095        }
14096    }
14097    unsafe impl<
14098            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
14099            T1: fidl::encoding::Encode<
14100                fidl::encoding::Boxed<VirtioImage>,
14101                fidl::encoding::DefaultFuchsiaResourceDialect,
14102            >,
14103        >
14104        fidl::encoding::Encode<
14105            VirtioWaylandImporterExportImageResponse,
14106            fidl::encoding::DefaultFuchsiaResourceDialect,
14107        > for (T0, T1)
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::<VirtioWaylandImporterExportImageResponse>(offset);
14120            // Zero out padding regions. There's no need to apply masks
14121            // because the unmasked parts will be overwritten by fields.
14122            unsafe {
14123                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
14124                (ptr as *mut u64).write_unaligned(0);
14125            }
14126            // Write the fields.
14127            self.0.encode(encoder, offset + 0, depth)?;
14128            self.1.encode(encoder, offset + 8, depth)?;
14129            Ok(())
14130        }
14131    }
14132
14133    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14134        for VirtioWaylandImporterExportImageResponse
14135    {
14136        #[inline(always)]
14137        fn new_empty() -> Self {
14138            Self {
14139                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
14140                image: fidl::new_empty!(
14141                    fidl::encoding::Boxed<VirtioImage>,
14142                    fidl::encoding::DefaultFuchsiaResourceDialect
14143                ),
14144            }
14145        }
14146
14147        #[inline]
14148        unsafe fn decode(
14149            &mut self,
14150            decoder: &mut fidl::encoding::Decoder<
14151                '_,
14152                fidl::encoding::DefaultFuchsiaResourceDialect,
14153            >,
14154            offset: usize,
14155            _depth: fidl::encoding::Depth,
14156        ) -> fidl::Result<()> {
14157            decoder.debug_check_bounds::<Self>(offset);
14158            // Verify that padding bytes are zero.
14159            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
14160            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14161            let mask = 0xffffffff00000000u64;
14162            let maskedval = padval & mask;
14163            if maskedval != 0 {
14164                return Err(fidl::Error::NonZeroPadding {
14165                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
14166                });
14167            }
14168            fidl::decode!(
14169                i32,
14170                fidl::encoding::DefaultFuchsiaResourceDialect,
14171                &mut self.status,
14172                decoder,
14173                offset + 0,
14174                _depth
14175            )?;
14176            fidl::decode!(
14177                fidl::encoding::Boxed<VirtioImage>,
14178                fidl::encoding::DefaultFuchsiaResourceDialect,
14179                &mut self.image,
14180                decoder,
14181                offset + 8,
14182                _depth
14183            )?;
14184            Ok(())
14185        }
14186    }
14187
14188    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandImporterImportImageRequest {
14189        type Borrowed<'a> = &'a mut Self;
14190        fn take_or_borrow<'a>(
14191            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14192        ) -> Self::Borrowed<'a> {
14193            value
14194        }
14195    }
14196
14197    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandImporterImportImageRequest {
14198        type Owned = Self;
14199
14200        #[inline(always)]
14201        fn inline_align(_context: fidl::encoding::Context) -> usize {
14202            8
14203        }
14204
14205        #[inline(always)]
14206        fn inline_size(_context: fidl::encoding::Context) -> usize {
14207            24
14208        }
14209    }
14210
14211    unsafe impl
14212        fidl::encoding::Encode<
14213            VirtioWaylandImporterImportImageRequest,
14214            fidl::encoding::DefaultFuchsiaResourceDialect,
14215        > for &mut VirtioWaylandImporterImportImageRequest
14216    {
14217        #[inline]
14218        unsafe fn encode(
14219            self,
14220            encoder: &mut fidl::encoding::Encoder<
14221                '_,
14222                fidl::encoding::DefaultFuchsiaResourceDialect,
14223            >,
14224            offset: usize,
14225            _depth: fidl::encoding::Depth,
14226        ) -> fidl::Result<()> {
14227            encoder.debug_check_bounds::<VirtioWaylandImporterImportImageRequest>(offset);
14228            // Delegate to tuple encoding.
14229            fidl::encoding::Encode::<
14230                VirtioWaylandImporterImportImageRequest,
14231                fidl::encoding::DefaultFuchsiaResourceDialect,
14232            >::encode(
14233                (<VirtioImage as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14234                    &mut self.image,
14235                ),),
14236                encoder,
14237                offset,
14238                _depth,
14239            )
14240        }
14241    }
14242    unsafe impl<
14243            T0: fidl::encoding::Encode<VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect>,
14244        >
14245        fidl::encoding::Encode<
14246            VirtioWaylandImporterImportImageRequest,
14247            fidl::encoding::DefaultFuchsiaResourceDialect,
14248        > for (T0,)
14249    {
14250        #[inline]
14251        unsafe fn encode(
14252            self,
14253            encoder: &mut fidl::encoding::Encoder<
14254                '_,
14255                fidl::encoding::DefaultFuchsiaResourceDialect,
14256            >,
14257            offset: usize,
14258            depth: fidl::encoding::Depth,
14259        ) -> fidl::Result<()> {
14260            encoder.debug_check_bounds::<VirtioWaylandImporterImportImageRequest>(offset);
14261            // Zero out padding regions. There's no need to apply masks
14262            // because the unmasked parts will be overwritten by fields.
14263            // Write the fields.
14264            self.0.encode(encoder, offset + 0, depth)?;
14265            Ok(())
14266        }
14267    }
14268
14269    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14270        for VirtioWaylandImporterImportImageRequest
14271    {
14272        #[inline(always)]
14273        fn new_empty() -> Self {
14274            Self {
14275                image: fidl::new_empty!(VirtioImage, fidl::encoding::DefaultFuchsiaResourceDialect),
14276            }
14277        }
14278
14279        #[inline]
14280        unsafe fn decode(
14281            &mut self,
14282            decoder: &mut fidl::encoding::Decoder<
14283                '_,
14284                fidl::encoding::DefaultFuchsiaResourceDialect,
14285            >,
14286            offset: usize,
14287            _depth: fidl::encoding::Depth,
14288        ) -> fidl::Result<()> {
14289            decoder.debug_check_bounds::<Self>(offset);
14290            // Verify that padding bytes are zero.
14291            fidl::decode!(
14292                VirtioImage,
14293                fidl::encoding::DefaultFuchsiaResourceDialect,
14294                &mut self.image,
14295                decoder,
14296                offset + 0,
14297                _depth
14298            )?;
14299            Ok(())
14300        }
14301    }
14302
14303    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandStartRequest {
14304        type Borrowed<'a> = &'a mut Self;
14305        fn take_or_borrow<'a>(
14306            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14307        ) -> Self::Borrowed<'a> {
14308            value
14309        }
14310    }
14311
14312    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandStartRequest {
14313        type Owned = Self;
14314
14315        #[inline(always)]
14316        fn inline_align(_context: fidl::encoding::Context) -> usize {
14317            8
14318        }
14319
14320        #[inline(always)]
14321        fn inline_size(_context: fidl::encoding::Context) -> usize {
14322            48
14323        }
14324    }
14325
14326    unsafe impl
14327        fidl::encoding::Encode<
14328            VirtioWaylandStartRequest,
14329            fidl::encoding::DefaultFuchsiaResourceDialect,
14330        > for &mut VirtioWaylandStartRequest
14331    {
14332        #[inline]
14333        unsafe fn encode(
14334            self,
14335            encoder: &mut fidl::encoding::Encoder<
14336                '_,
14337                fidl::encoding::DefaultFuchsiaResourceDialect,
14338            >,
14339            offset: usize,
14340            _depth: fidl::encoding::Depth,
14341        ) -> fidl::Result<()> {
14342            encoder.debug_check_bounds::<VirtioWaylandStartRequest>(offset);
14343            // Delegate to tuple encoding.
14344            fidl::encoding::Encode::<
14345                VirtioWaylandStartRequest,
14346                fidl::encoding::DefaultFuchsiaResourceDialect,
14347            >::encode(
14348                (
14349                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14350                        &mut self.start_info,
14351                    ),
14352                    <fidl::encoding::HandleType<
14353                        fidl::Vmar,
14354                        { fidl::ObjectType::VMAR.into_raw() },
14355                        2147483648,
14356                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14357                        &mut self.vmar
14358                    ),
14359                    <fidl::encoding::Endpoint<
14360                        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14361                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14362                        &mut self.sysmem_allocator,
14363                    ),
14364                    <fidl::encoding::Endpoint<
14365                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14366                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14367                        &mut self.scenic_allocator,
14368                    ),
14369                ),
14370                encoder,
14371                offset,
14372                _depth,
14373            )
14374        }
14375    }
14376    unsafe impl<
14377            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
14378            T1: fidl::encoding::Encode<
14379                fidl::encoding::HandleType<
14380                    fidl::Vmar,
14381                    { fidl::ObjectType::VMAR.into_raw() },
14382                    2147483648,
14383                >,
14384                fidl::encoding::DefaultFuchsiaResourceDialect,
14385            >,
14386            T2: fidl::encoding::Encode<
14387                fidl::encoding::Endpoint<
14388                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14389                >,
14390                fidl::encoding::DefaultFuchsiaResourceDialect,
14391            >,
14392            T3: fidl::encoding::Encode<
14393                fidl::encoding::Endpoint<
14394                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14395                >,
14396                fidl::encoding::DefaultFuchsiaResourceDialect,
14397            >,
14398        >
14399        fidl::encoding::Encode<
14400            VirtioWaylandStartRequest,
14401            fidl::encoding::DefaultFuchsiaResourceDialect,
14402        > for (T0, T1, T2, T3)
14403    {
14404        #[inline]
14405        unsafe fn encode(
14406            self,
14407            encoder: &mut fidl::encoding::Encoder<
14408                '_,
14409                fidl::encoding::DefaultFuchsiaResourceDialect,
14410            >,
14411            offset: usize,
14412            depth: fidl::encoding::Depth,
14413        ) -> fidl::Result<()> {
14414            encoder.debug_check_bounds::<VirtioWaylandStartRequest>(offset);
14415            // Zero out padding regions. There's no need to apply masks
14416            // because the unmasked parts will be overwritten by fields.
14417            unsafe {
14418                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
14419                (ptr as *mut u64).write_unaligned(0);
14420            }
14421            // Write the fields.
14422            self.0.encode(encoder, offset + 0, depth)?;
14423            self.1.encode(encoder, offset + 32, depth)?;
14424            self.2.encode(encoder, offset + 36, depth)?;
14425            self.3.encode(encoder, offset + 40, depth)?;
14426            Ok(())
14427        }
14428    }
14429
14430    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14431        for VirtioWaylandStartRequest
14432    {
14433        #[inline(always)]
14434        fn new_empty() -> Self {
14435            Self {
14436                start_info: fidl::new_empty!(
14437                    StartInfo,
14438                    fidl::encoding::DefaultFuchsiaResourceDialect
14439                ),
14440                vmar: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14441                sysmem_allocator: fidl::new_empty!(
14442                    fidl::encoding::Endpoint<
14443                        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14444                    >,
14445                    fidl::encoding::DefaultFuchsiaResourceDialect
14446                ),
14447                scenic_allocator: fidl::new_empty!(
14448                    fidl::encoding::Endpoint<
14449                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14450                    >,
14451                    fidl::encoding::DefaultFuchsiaResourceDialect
14452                ),
14453            }
14454        }
14455
14456        #[inline]
14457        unsafe fn decode(
14458            &mut self,
14459            decoder: &mut fidl::encoding::Decoder<
14460                '_,
14461                fidl::encoding::DefaultFuchsiaResourceDialect,
14462            >,
14463            offset: usize,
14464            _depth: fidl::encoding::Depth,
14465        ) -> fidl::Result<()> {
14466            decoder.debug_check_bounds::<Self>(offset);
14467            // Verify that padding bytes are zero.
14468            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
14469            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14470            let mask = 0xffffffff00000000u64;
14471            let maskedval = padval & mask;
14472            if maskedval != 0 {
14473                return Err(fidl::Error::NonZeroPadding {
14474                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
14475                });
14476            }
14477            fidl::decode!(
14478                StartInfo,
14479                fidl::encoding::DefaultFuchsiaResourceDialect,
14480                &mut self.start_info,
14481                decoder,
14482                offset + 0,
14483                _depth
14484            )?;
14485            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar, decoder, offset + 32, _depth)?;
14486            fidl::decode!(
14487                fidl::encoding::Endpoint<
14488                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14489                >,
14490                fidl::encoding::DefaultFuchsiaResourceDialect,
14491                &mut self.sysmem_allocator,
14492                decoder,
14493                offset + 36,
14494                _depth
14495            )?;
14496            fidl::decode!(
14497                fidl::encoding::Endpoint<
14498                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14499                >,
14500                fidl::encoding::DefaultFuchsiaResourceDialect,
14501                &mut self.scenic_allocator,
14502                decoder,
14503                offset + 40,
14504                _depth
14505            )?;
14506            Ok(())
14507        }
14508    }
14509
14510    impl fidl::encoding::ResourceTypeMarker for VirtioWaylandStartWithWaylandServerRequest {
14511        type Borrowed<'a> = &'a mut Self;
14512        fn take_or_borrow<'a>(
14513            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14514        ) -> Self::Borrowed<'a> {
14515            value
14516        }
14517    }
14518
14519    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandStartWithWaylandServerRequest {
14520        type Owned = Self;
14521
14522        #[inline(always)]
14523        fn inline_align(_context: fidl::encoding::Context) -> usize {
14524            8
14525        }
14526
14527        #[inline(always)]
14528        fn inline_size(_context: fidl::encoding::Context) -> usize {
14529            48
14530        }
14531    }
14532
14533    unsafe impl
14534        fidl::encoding::Encode<
14535            VirtioWaylandStartWithWaylandServerRequest,
14536            fidl::encoding::DefaultFuchsiaResourceDialect,
14537        > for &mut VirtioWaylandStartWithWaylandServerRequest
14538    {
14539        #[inline]
14540        unsafe fn encode(
14541            self,
14542            encoder: &mut fidl::encoding::Encoder<
14543                '_,
14544                fidl::encoding::DefaultFuchsiaResourceDialect,
14545            >,
14546            offset: usize,
14547            _depth: fidl::encoding::Depth,
14548        ) -> fidl::Result<()> {
14549            encoder.debug_check_bounds::<VirtioWaylandStartWithWaylandServerRequest>(offset);
14550            // Delegate to tuple encoding.
14551            fidl::encoding::Encode::<
14552                VirtioWaylandStartWithWaylandServerRequest,
14553                fidl::encoding::DefaultFuchsiaResourceDialect,
14554            >::encode(
14555                (
14556                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14557                        &mut self.start_info,
14558                    ),
14559                    <fidl::encoding::HandleType<
14560                        fidl::Vmar,
14561                        { fidl::ObjectType::VMAR.into_raw() },
14562                        2147483648,
14563                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14564                        &mut self.vmar
14565                    ),
14566                    <fidl::encoding::Optional<
14567                        fidl::encoding::Endpoint<
14568                            fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
14569                        >,
14570                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14571                        &mut self.wayland_server,
14572                    ),
14573                    <fidl::encoding::Endpoint<
14574                        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14575                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14576                        &mut self.sysmem_allocator,
14577                    ),
14578                    <fidl::encoding::Endpoint<
14579                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14580                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14581                        &mut self.scenic_allocator,
14582                    ),
14583                ),
14584                encoder,
14585                offset,
14586                _depth,
14587            )
14588        }
14589    }
14590    unsafe impl<
14591            T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
14592            T1: fidl::encoding::Encode<
14593                fidl::encoding::HandleType<
14594                    fidl::Vmar,
14595                    { fidl::ObjectType::VMAR.into_raw() },
14596                    2147483648,
14597                >,
14598                fidl::encoding::DefaultFuchsiaResourceDialect,
14599            >,
14600            T2: fidl::encoding::Encode<
14601                fidl::encoding::Optional<
14602                    fidl::encoding::Endpoint<
14603                        fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
14604                    >,
14605                >,
14606                fidl::encoding::DefaultFuchsiaResourceDialect,
14607            >,
14608            T3: fidl::encoding::Encode<
14609                fidl::encoding::Endpoint<
14610                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14611                >,
14612                fidl::encoding::DefaultFuchsiaResourceDialect,
14613            >,
14614            T4: fidl::encoding::Encode<
14615                fidl::encoding::Endpoint<
14616                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14617                >,
14618                fidl::encoding::DefaultFuchsiaResourceDialect,
14619            >,
14620        >
14621        fidl::encoding::Encode<
14622            VirtioWaylandStartWithWaylandServerRequest,
14623            fidl::encoding::DefaultFuchsiaResourceDialect,
14624        > for (T0, T1, T2, T3, T4)
14625    {
14626        #[inline]
14627        unsafe fn encode(
14628            self,
14629            encoder: &mut fidl::encoding::Encoder<
14630                '_,
14631                fidl::encoding::DefaultFuchsiaResourceDialect,
14632            >,
14633            offset: usize,
14634            depth: fidl::encoding::Depth,
14635        ) -> fidl::Result<()> {
14636            encoder.debug_check_bounds::<VirtioWaylandStartWithWaylandServerRequest>(offset);
14637            // Zero out padding regions. There's no need to apply masks
14638            // because the unmasked parts will be overwritten by fields.
14639            // Write the fields.
14640            self.0.encode(encoder, offset + 0, depth)?;
14641            self.1.encode(encoder, offset + 32, depth)?;
14642            self.2.encode(encoder, offset + 36, depth)?;
14643            self.3.encode(encoder, offset + 40, depth)?;
14644            self.4.encode(encoder, offset + 44, depth)?;
14645            Ok(())
14646        }
14647    }
14648
14649    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14650        for VirtioWaylandStartWithWaylandServerRequest
14651    {
14652        #[inline(always)]
14653        fn new_empty() -> Self {
14654            Self {
14655                start_info: fidl::new_empty!(
14656                    StartInfo,
14657                    fidl::encoding::DefaultFuchsiaResourceDialect
14658                ),
14659                vmar: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14660                wayland_server: fidl::new_empty!(
14661                    fidl::encoding::Optional<
14662                        fidl::encoding::Endpoint<
14663                            fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
14664                        >,
14665                    >,
14666                    fidl::encoding::DefaultFuchsiaResourceDialect
14667                ),
14668                sysmem_allocator: fidl::new_empty!(
14669                    fidl::encoding::Endpoint<
14670                        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14671                    >,
14672                    fidl::encoding::DefaultFuchsiaResourceDialect
14673                ),
14674                scenic_allocator: fidl::new_empty!(
14675                    fidl::encoding::Endpoint<
14676                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14677                    >,
14678                    fidl::encoding::DefaultFuchsiaResourceDialect
14679                ),
14680            }
14681        }
14682
14683        #[inline]
14684        unsafe fn decode(
14685            &mut self,
14686            decoder: &mut fidl::encoding::Decoder<
14687                '_,
14688                fidl::encoding::DefaultFuchsiaResourceDialect,
14689            >,
14690            offset: usize,
14691            _depth: fidl::encoding::Depth,
14692        ) -> fidl::Result<()> {
14693            decoder.debug_check_bounds::<Self>(offset);
14694            // Verify that padding bytes are zero.
14695            fidl::decode!(
14696                StartInfo,
14697                fidl::encoding::DefaultFuchsiaResourceDialect,
14698                &mut self.start_info,
14699                decoder,
14700                offset + 0,
14701                _depth
14702            )?;
14703            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar, decoder, offset + 32, _depth)?;
14704            fidl::decode!(
14705                fidl::encoding::Optional<
14706                    fidl::encoding::Endpoint<
14707                        fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>,
14708                    >,
14709                >,
14710                fidl::encoding::DefaultFuchsiaResourceDialect,
14711                &mut self.wayland_server,
14712                decoder,
14713                offset + 36,
14714                _depth
14715            )?;
14716            fidl::decode!(
14717                fidl::encoding::Endpoint<
14718                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
14719                >,
14720                fidl::encoding::DefaultFuchsiaResourceDialect,
14721                &mut self.sysmem_allocator,
14722                decoder,
14723                offset + 40,
14724                _depth
14725            )?;
14726            fidl::decode!(
14727                fidl::encoding::Endpoint<
14728                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
14729                >,
14730                fidl::encoding::DefaultFuchsiaResourceDialect,
14731                &mut self.scenic_allocator,
14732                decoder,
14733                offset + 44,
14734                _depth
14735            )?;
14736            Ok(())
14737        }
14738    }
14739
14740    impl fidl::encoding::ResourceTypeMarker for InputType {
14741        type Borrowed<'a> = &'a mut Self;
14742        fn take_or_borrow<'a>(
14743            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14744        ) -> Self::Borrowed<'a> {
14745            value
14746        }
14747    }
14748
14749    unsafe impl fidl::encoding::TypeMarker for InputType {
14750        type Owned = Self;
14751
14752        #[inline(always)]
14753        fn inline_align(_context: fidl::encoding::Context) -> usize {
14754            8
14755        }
14756
14757        #[inline(always)]
14758        fn inline_size(_context: fidl::encoding::Context) -> usize {
14759            16
14760        }
14761    }
14762
14763    unsafe impl fidl::encoding::Encode<InputType, fidl::encoding::DefaultFuchsiaResourceDialect>
14764        for &mut InputType
14765    {
14766        #[inline]
14767        unsafe fn encode(
14768            self,
14769            encoder: &mut fidl::encoding::Encoder<
14770                '_,
14771                fidl::encoding::DefaultFuchsiaResourceDialect,
14772            >,
14773            offset: usize,
14774            _depth: fidl::encoding::Depth,
14775        ) -> fidl::Result<()> {
14776            encoder.debug_check_bounds::<InputType>(offset);
14777            encoder.write_num::<u64>(self.ordinal(), offset);
14778            match self {
14779                InputType::Keyboard(ref mut val) => fidl::encoding::encode_in_envelope::<
14780                    fidl::encoding::Endpoint<
14781                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
14782                    >,
14783                    fidl::encoding::DefaultFuchsiaResourceDialect,
14784                >(
14785                    <fidl::encoding::Endpoint<
14786                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
14787                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14788                        val
14789                    ),
14790                    encoder,
14791                    offset + 8,
14792                    _depth,
14793                ),
14794                InputType::Mouse(ref mut val) => fidl::encoding::encode_in_envelope::<
14795                    fidl::encoding::Endpoint<
14796                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14797                    >,
14798                    fidl::encoding::DefaultFuchsiaResourceDialect,
14799                >(
14800                    <fidl::encoding::Endpoint<
14801                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14802                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14803                        val
14804                    ),
14805                    encoder,
14806                    offset + 8,
14807                    _depth,
14808                ),
14809            }
14810        }
14811    }
14812
14813    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for InputType {
14814        #[inline(always)]
14815        fn new_empty() -> Self {
14816            Self::Keyboard(fidl::new_empty!(
14817                fidl::encoding::Endpoint<
14818                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
14819                >,
14820                fidl::encoding::DefaultFuchsiaResourceDialect
14821            ))
14822        }
14823
14824        #[inline]
14825        unsafe fn decode(
14826            &mut self,
14827            decoder: &mut fidl::encoding::Decoder<
14828                '_,
14829                fidl::encoding::DefaultFuchsiaResourceDialect,
14830            >,
14831            offset: usize,
14832            mut depth: fidl::encoding::Depth,
14833        ) -> fidl::Result<()> {
14834            decoder.debug_check_bounds::<Self>(offset);
14835            #[allow(unused_variables)]
14836            let next_out_of_line = decoder.next_out_of_line();
14837            let handles_before = decoder.remaining_handles();
14838            let (ordinal, inlined, num_bytes, num_handles) =
14839                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
14840
14841            let member_inline_size = match ordinal {
14842                1 => <fidl::encoding::Endpoint<
14843                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
14844                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
14845                2 => <fidl::encoding::Endpoint<
14846                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14847                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
14848                _ => return Err(fidl::Error::UnknownUnionTag),
14849            };
14850
14851            if inlined != (member_inline_size <= 4) {
14852                return Err(fidl::Error::InvalidInlineBitInEnvelope);
14853            }
14854            let _inner_offset;
14855            if inlined {
14856                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
14857                _inner_offset = offset + 8;
14858            } else {
14859                depth.increment()?;
14860                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14861            }
14862            match ordinal {
14863                1 => {
14864                    #[allow(irrefutable_let_patterns)]
14865                    if let InputType::Keyboard(_) = self {
14866                        // Do nothing, read the value into the object
14867                    } else {
14868                        // Initialize `self` to the right variant
14869                        *self = InputType::Keyboard(fidl::new_empty!(
14870                            fidl::encoding::Endpoint<
14871                                fidl::endpoints::ServerEnd<
14872                                    fidl_fuchsia_ui_input3::KeyboardListenerMarker,
14873                                >,
14874                            >,
14875                            fidl::encoding::DefaultFuchsiaResourceDialect
14876                        ));
14877                    }
14878                    #[allow(irrefutable_let_patterns)]
14879                    if let InputType::Keyboard(ref mut val) = self {
14880                        fidl::decode!(
14881                            fidl::encoding::Endpoint<
14882                                fidl::endpoints::ServerEnd<
14883                                    fidl_fuchsia_ui_input3::KeyboardListenerMarker,
14884                                >,
14885                            >,
14886                            fidl::encoding::DefaultFuchsiaResourceDialect,
14887                            val,
14888                            decoder,
14889                            _inner_offset,
14890                            depth
14891                        )?;
14892                    } else {
14893                        unreachable!()
14894                    }
14895                }
14896                2 => {
14897                    #[allow(irrefutable_let_patterns)]
14898                    if let InputType::Mouse(_) = self {
14899                        // Do nothing, read the value into the object
14900                    } else {
14901                        // Initialize `self` to the right variant
14902                        *self = InputType::Mouse(fidl::new_empty!(
14903                            fidl::encoding::Endpoint<
14904                                fidl::endpoints::ClientEnd<
14905                                    fidl_fuchsia_ui_pointer::MouseSourceMarker,
14906                                >,
14907                            >,
14908                            fidl::encoding::DefaultFuchsiaResourceDialect
14909                        ));
14910                    }
14911                    #[allow(irrefutable_let_patterns)]
14912                    if let InputType::Mouse(ref mut val) = self {
14913                        fidl::decode!(
14914                            fidl::encoding::Endpoint<
14915                                fidl::endpoints::ClientEnd<
14916                                    fidl_fuchsia_ui_pointer::MouseSourceMarker,
14917                                >,
14918                            >,
14919                            fidl::encoding::DefaultFuchsiaResourceDialect,
14920                            val,
14921                            decoder,
14922                            _inner_offset,
14923                            depth
14924                        )?;
14925                    } else {
14926                        unreachable!()
14927                    }
14928                }
14929                ordinal => panic!("unexpected ordinal {:?}", ordinal),
14930            }
14931            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
14932                return Err(fidl::Error::InvalidNumBytesInEnvelope);
14933            }
14934            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14935                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14936            }
14937            Ok(())
14938        }
14939    }
14940}