Skip to main content

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#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
70pub struct VirtioInputStartRequest {
71    pub start_info: StartInfo,
72    pub input_type: InputType,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioInputStartRequest {}
76
77#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
78pub struct VirtioMemStartRequest {
79    pub start_info: StartInfo,
80    pub region_addr: u64,
81    pub plugged_block_size: u64,
82    pub region_size: u64,
83}
84
85impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioMemStartRequest {}
86
87#[derive(Debug, PartialEq)]
88pub struct VirtioNetStartRequest {
89    pub start_info: StartInfo,
90    pub mac_address: fidl_fuchsia_net::MacAddress,
91    pub enable_bridge: bool,
92}
93
94impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioNetStartRequest {}
95
96#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
97pub struct VirtioRngStartRequest {
98    pub start_info: StartInfo,
99}
100
101impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioRngStartRequest {}
102
103#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
104pub struct VirtioSoundStartRequest {
105    pub start_info: StartInfo,
106    pub enable_input: bool,
107    pub enable_verbose_logging: bool,
108}
109
110impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioSoundStartRequest {}
111
112#[derive(Debug, PartialEq)]
113pub struct VirtioVsockStartRequest {
114    pub start_info: StartInfo,
115    pub guest_cid: u32,
116    pub listeners: Vec<fidl_fuchsia_virtualization::Listener>,
117}
118
119impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VirtioVsockStartRequest {}
120
121#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
122pub enum InputType {
123    Keyboard(fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>),
124    Mouse(fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>),
125}
126
127impl InputType {
128    #[inline]
129    pub fn ordinal(&self) -> u64 {
130        match *self {
131            Self::Keyboard(_) => 1,
132            Self::Mouse(_) => 2,
133        }
134    }
135}
136
137impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InputType {}
138
139#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
140pub struct VirtioBalloonMarker;
141
142impl fidl::endpoints::ProtocolMarker for VirtioBalloonMarker {
143    type Proxy = VirtioBalloonProxy;
144    type RequestStream = VirtioBalloonRequestStream;
145    #[cfg(target_os = "fuchsia")]
146    type SynchronousProxy = VirtioBalloonSynchronousProxy;
147
148    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioBalloon";
149}
150impl fidl::endpoints::DiscoverableProtocolMarker for VirtioBalloonMarker {}
151
152pub trait VirtioBalloonProxyInterface: Send + Sync {
153    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
154    fn r#configure_queue(
155        &self,
156        queue: u16,
157        size: u16,
158        desc: u64,
159        avail: u64,
160        used: u64,
161    ) -> Self::ConfigureQueueResponseFut;
162    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
163    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
164    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
165    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
166    fn r#start(&self, start_info: StartInfo) -> Self::StartResponseFut;
167    type GetMemStatsResponseFut: std::future::Future<
168            Output = Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error>,
169        > + Send;
170    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut;
171}
172#[derive(Debug)]
173#[cfg(target_os = "fuchsia")]
174pub struct VirtioBalloonSynchronousProxy {
175    client: fidl::client::sync::Client,
176}
177
178#[cfg(target_os = "fuchsia")]
179impl fidl::endpoints::SynchronousProxy for VirtioBalloonSynchronousProxy {
180    type Proxy = VirtioBalloonProxy;
181    type Protocol = VirtioBalloonMarker;
182
183    fn from_channel(inner: fidl::Channel) -> Self {
184        Self::new(inner)
185    }
186
187    fn into_channel(self) -> fidl::Channel {
188        self.client.into_channel()
189    }
190
191    fn as_channel(&self) -> &fidl::Channel {
192        self.client.as_channel()
193    }
194}
195
196#[cfg(target_os = "fuchsia")]
197impl VirtioBalloonSynchronousProxy {
198    pub fn new(channel: fidl::Channel) -> Self {
199        Self { client: fidl::client::sync::Client::new(channel) }
200    }
201
202    pub fn into_channel(self) -> fidl::Channel {
203        self.client.into_channel()
204    }
205
206    /// Waits until an event arrives and returns it. It is safe for other
207    /// threads to make concurrent requests while waiting for an event.
208    pub fn wait_for_event(
209        &self,
210        deadline: zx::MonotonicInstant,
211    ) -> Result<VirtioBalloonEvent, fidl::Error> {
212        VirtioBalloonEvent::decode(self.client.wait_for_event::<VirtioBalloonMarker>(deadline)?)
213    }
214
215    /// Configure a `queue` for the device. This specifies the `size` and the
216    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
217    pub fn r#configure_queue(
218        &self,
219        mut queue: u16,
220        mut size: u16,
221        mut desc: u64,
222        mut avail: u64,
223        mut used: u64,
224        ___deadline: zx::MonotonicInstant,
225    ) -> Result<(), fidl::Error> {
226        let _response = self.client.send_query::<
227            VirtioDeviceConfigureQueueRequest,
228            fidl::encoding::EmptyPayload,
229            VirtioBalloonMarker,
230        >(
231            (queue, size, desc, avail, used,),
232            0x72b44fb963480b11,
233            fidl::encoding::DynamicFlags::empty(),
234            ___deadline,
235        )?;
236        Ok(_response)
237    }
238
239    /// Notify a `queue` for the device. Primarily used for black-box testing.
240    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
241        self.client.send::<VirtioDeviceNotifyQueueRequest>(
242            (queue,),
243            0x6e3a61d652499244,
244            fidl::encoding::DynamicFlags::empty(),
245        )
246    }
247
248    /// Ready a device. This provides the set of `negotiated_features` that the
249    /// driver and device have agreed upon.
250    pub fn r#ready(
251        &self,
252        mut negotiated_features: u32,
253        ___deadline: zx::MonotonicInstant,
254    ) -> Result<(), fidl::Error> {
255        let _response = self.client.send_query::<
256            VirtioDeviceReadyRequest,
257            fidl::encoding::EmptyPayload,
258            VirtioBalloonMarker,
259        >(
260            (negotiated_features,),
261            0x45707654f5d23c3f,
262            fidl::encoding::DynamicFlags::empty(),
263            ___deadline,
264        )?;
265        Ok(_response)
266    }
267
268    /// Start the balloon device.
269    pub fn r#start(
270        &self,
271        mut start_info: StartInfo,
272        ___deadline: zx::MonotonicInstant,
273    ) -> Result<(), fidl::Error> {
274        let _response = self.client.send_query::<
275            VirtioBalloonStartRequest,
276            fidl::encoding::EmptyPayload,
277            VirtioBalloonMarker,
278        >(
279            (&mut start_info,),
280            0x26645282fddf6f46,
281            fidl::encoding::DynamicFlags::empty(),
282            ___deadline,
283        )?;
284        Ok(_response)
285    }
286
287    /// Get memory statistics from the balloon device.
288    pub fn r#get_mem_stats(
289        &self,
290        ___deadline: zx::MonotonicInstant,
291    ) -> Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error> {
292        let _response = self.client.send_query::<
293            fidl::encoding::EmptyPayload,
294            VirtioBalloonGetMemStatsResponse,
295            VirtioBalloonMarker,
296        >(
297            (),
298            0x6641f4c296607e24,
299            fidl::encoding::DynamicFlags::empty(),
300            ___deadline,
301        )?;
302        Ok((_response.status, _response.mem_stats))
303    }
304}
305
306#[cfg(target_os = "fuchsia")]
307impl From<VirtioBalloonSynchronousProxy> for zx::NullableHandle {
308    fn from(value: VirtioBalloonSynchronousProxy) -> Self {
309        value.into_channel().into()
310    }
311}
312
313#[cfg(target_os = "fuchsia")]
314impl From<fidl::Channel> for VirtioBalloonSynchronousProxy {
315    fn from(value: fidl::Channel) -> Self {
316        Self::new(value)
317    }
318}
319
320#[cfg(target_os = "fuchsia")]
321impl fidl::endpoints::FromClient for VirtioBalloonSynchronousProxy {
322    type Protocol = VirtioBalloonMarker;
323
324    fn from_client(value: fidl::endpoints::ClientEnd<VirtioBalloonMarker>) -> Self {
325        Self::new(value.into_channel())
326    }
327}
328
329#[derive(Debug, Clone)]
330pub struct VirtioBalloonProxy {
331    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
332}
333
334impl fidl::endpoints::Proxy for VirtioBalloonProxy {
335    type Protocol = VirtioBalloonMarker;
336
337    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
338        Self::new(inner)
339    }
340
341    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
342        self.client.into_channel().map_err(|client| Self { client })
343    }
344
345    fn as_channel(&self) -> &::fidl::AsyncChannel {
346        self.client.as_channel()
347    }
348}
349
350impl VirtioBalloonProxy {
351    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioBalloon.
352    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
353        let protocol_name = <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
354        Self { client: fidl::client::Client::new(channel, protocol_name) }
355    }
356
357    /// Get a Stream of events from the remote end of the protocol.
358    ///
359    /// # Panics
360    ///
361    /// Panics if the event stream was already taken.
362    pub fn take_event_stream(&self) -> VirtioBalloonEventStream {
363        VirtioBalloonEventStream { event_receiver: self.client.take_event_receiver() }
364    }
365
366    /// Configure a `queue` for the device. This specifies the `size` and the
367    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
368    pub fn r#configure_queue(
369        &self,
370        mut queue: u16,
371        mut size: u16,
372        mut desc: u64,
373        mut avail: u64,
374        mut used: u64,
375    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
376        VirtioBalloonProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
377    }
378
379    /// Notify a `queue` for the device. Primarily used for black-box testing.
380    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
381        VirtioBalloonProxyInterface::r#notify_queue(self, queue)
382    }
383
384    /// Ready a device. This provides the set of `negotiated_features` that the
385    /// driver and device have agreed upon.
386    pub fn r#ready(
387        &self,
388        mut negotiated_features: u32,
389    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
390        VirtioBalloonProxyInterface::r#ready(self, negotiated_features)
391    }
392
393    /// Start the balloon device.
394    pub fn r#start(
395        &self,
396        mut start_info: StartInfo,
397    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
398        VirtioBalloonProxyInterface::r#start(self, start_info)
399    }
400
401    /// Get memory statistics from the balloon device.
402    pub fn r#get_mem_stats(
403        &self,
404    ) -> fidl::client::QueryResponseFut<
405        (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
406        fidl::encoding::DefaultFuchsiaResourceDialect,
407    > {
408        VirtioBalloonProxyInterface::r#get_mem_stats(self)
409    }
410}
411
412impl VirtioBalloonProxyInterface for VirtioBalloonProxy {
413    type ConfigureQueueResponseFut =
414        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
415    fn r#configure_queue(
416        &self,
417        mut queue: u16,
418        mut size: u16,
419        mut desc: u64,
420        mut avail: u64,
421        mut used: u64,
422    ) -> Self::ConfigureQueueResponseFut {
423        fn _decode(
424            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
425        ) -> Result<(), fidl::Error> {
426            let _response = fidl::client::decode_transaction_body::<
427                fidl::encoding::EmptyPayload,
428                fidl::encoding::DefaultFuchsiaResourceDialect,
429                0x72b44fb963480b11,
430            >(_buf?)?;
431            Ok(_response)
432        }
433        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
434            (queue, size, desc, avail, used),
435            0x72b44fb963480b11,
436            fidl::encoding::DynamicFlags::empty(),
437            _decode,
438        )
439    }
440
441    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
442        self.client.send::<VirtioDeviceNotifyQueueRequest>(
443            (queue,),
444            0x6e3a61d652499244,
445            fidl::encoding::DynamicFlags::empty(),
446        )
447    }
448
449    type ReadyResponseFut =
450        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
451    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
452        fn _decode(
453            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
454        ) -> Result<(), fidl::Error> {
455            let _response = fidl::client::decode_transaction_body::<
456                fidl::encoding::EmptyPayload,
457                fidl::encoding::DefaultFuchsiaResourceDialect,
458                0x45707654f5d23c3f,
459            >(_buf?)?;
460            Ok(_response)
461        }
462        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
463            (negotiated_features,),
464            0x45707654f5d23c3f,
465            fidl::encoding::DynamicFlags::empty(),
466            _decode,
467        )
468    }
469
470    type StartResponseFut =
471        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
472    fn r#start(&self, mut start_info: StartInfo) -> Self::StartResponseFut {
473        fn _decode(
474            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
475        ) -> Result<(), fidl::Error> {
476            let _response = fidl::client::decode_transaction_body::<
477                fidl::encoding::EmptyPayload,
478                fidl::encoding::DefaultFuchsiaResourceDialect,
479                0x26645282fddf6f46,
480            >(_buf?)?;
481            Ok(_response)
482        }
483        self.client.send_query_and_decode::<VirtioBalloonStartRequest, ()>(
484            (&mut start_info,),
485            0x26645282fddf6f46,
486            fidl::encoding::DynamicFlags::empty(),
487            _decode,
488        )
489    }
490
491    type GetMemStatsResponseFut = fidl::client::QueryResponseFut<
492        (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
493        fidl::encoding::DefaultFuchsiaResourceDialect,
494    >;
495    fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut {
496        fn _decode(
497            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
498        ) -> Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error> {
499            let _response = fidl::client::decode_transaction_body::<
500                VirtioBalloonGetMemStatsResponse,
501                fidl::encoding::DefaultFuchsiaResourceDialect,
502                0x6641f4c296607e24,
503            >(_buf?)?;
504            Ok((_response.status, _response.mem_stats))
505        }
506        self.client.send_query_and_decode::<
507            fidl::encoding::EmptyPayload,
508            (i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
509        >(
510            (),
511            0x6641f4c296607e24,
512            fidl::encoding::DynamicFlags::empty(),
513            _decode,
514        )
515    }
516}
517
518pub struct VirtioBalloonEventStream {
519    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
520}
521
522impl std::marker::Unpin for VirtioBalloonEventStream {}
523
524impl futures::stream::FusedStream for VirtioBalloonEventStream {
525    fn is_terminated(&self) -> bool {
526        self.event_receiver.is_terminated()
527    }
528}
529
530impl futures::Stream for VirtioBalloonEventStream {
531    type Item = Result<VirtioBalloonEvent, fidl::Error>;
532
533    fn poll_next(
534        mut self: std::pin::Pin<&mut Self>,
535        cx: &mut std::task::Context<'_>,
536    ) -> std::task::Poll<Option<Self::Item>> {
537        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
538            &mut self.event_receiver,
539            cx
540        )?) {
541            Some(buf) => std::task::Poll::Ready(Some(VirtioBalloonEvent::decode(buf))),
542            None => std::task::Poll::Ready(None),
543        }
544    }
545}
546
547#[derive(Debug)]
548pub enum VirtioBalloonEvent {}
549
550impl VirtioBalloonEvent {
551    /// Decodes a message buffer as a [`VirtioBalloonEvent`].
552    fn decode(
553        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
554    ) -> Result<VirtioBalloonEvent, fidl::Error> {
555        let (bytes, _handles) = buf.split_mut();
556        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
557        debug_assert_eq!(tx_header.tx_id, 0);
558        match tx_header.ordinal {
559            _ => Err(fidl::Error::UnknownOrdinal {
560                ordinal: tx_header.ordinal,
561                protocol_name: <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
562            }),
563        }
564    }
565}
566
567/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioBalloon.
568pub struct VirtioBalloonRequestStream {
569    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
570    is_terminated: bool,
571}
572
573impl std::marker::Unpin for VirtioBalloonRequestStream {}
574
575impl futures::stream::FusedStream for VirtioBalloonRequestStream {
576    fn is_terminated(&self) -> bool {
577        self.is_terminated
578    }
579}
580
581impl fidl::endpoints::RequestStream for VirtioBalloonRequestStream {
582    type Protocol = VirtioBalloonMarker;
583    type ControlHandle = VirtioBalloonControlHandle;
584
585    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
586        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
587    }
588
589    fn control_handle(&self) -> Self::ControlHandle {
590        VirtioBalloonControlHandle { inner: self.inner.clone() }
591    }
592
593    fn into_inner(
594        self,
595    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
596    {
597        (self.inner, self.is_terminated)
598    }
599
600    fn from_inner(
601        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
602        is_terminated: bool,
603    ) -> Self {
604        Self { inner, is_terminated }
605    }
606}
607
608impl futures::Stream for VirtioBalloonRequestStream {
609    type Item = Result<VirtioBalloonRequest, fidl::Error>;
610
611    fn poll_next(
612        mut self: std::pin::Pin<&mut Self>,
613        cx: &mut std::task::Context<'_>,
614    ) -> std::task::Poll<Option<Self::Item>> {
615        let this = &mut *self;
616        if this.inner.check_shutdown(cx) {
617            this.is_terminated = true;
618            return std::task::Poll::Ready(None);
619        }
620        if this.is_terminated {
621            panic!("polled VirtioBalloonRequestStream after completion");
622        }
623        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
624            |bytes, handles| {
625                match this.inner.channel().read_etc(cx, bytes, handles) {
626                    std::task::Poll::Ready(Ok(())) => {}
627                    std::task::Poll::Pending => return std::task::Poll::Pending,
628                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
629                        this.is_terminated = true;
630                        return std::task::Poll::Ready(None);
631                    }
632                    std::task::Poll::Ready(Err(e)) => {
633                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
634                            e.into(),
635                        ))));
636                    }
637                }
638
639                // A message has been received from the channel
640                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
641
642                std::task::Poll::Ready(Some(match header.ordinal {
643                    0x72b44fb963480b11 => {
644                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
645                        let mut req = fidl::new_empty!(
646                            VirtioDeviceConfigureQueueRequest,
647                            fidl::encoding::DefaultFuchsiaResourceDialect
648                        );
649                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
650                        let control_handle =
651                            VirtioBalloonControlHandle { inner: this.inner.clone() };
652                        Ok(VirtioBalloonRequest::ConfigureQueue {
653                            queue: req.queue,
654                            size: req.size,
655                            desc: req.desc,
656                            avail: req.avail,
657                            used: req.used,
658
659                            responder: VirtioBalloonConfigureQueueResponder {
660                                control_handle: std::mem::ManuallyDrop::new(control_handle),
661                                tx_id: header.tx_id,
662                            },
663                        })
664                    }
665                    0x6e3a61d652499244 => {
666                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
667                        let mut req = fidl::new_empty!(
668                            VirtioDeviceNotifyQueueRequest,
669                            fidl::encoding::DefaultFuchsiaResourceDialect
670                        );
671                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
672                        let control_handle =
673                            VirtioBalloonControlHandle { inner: this.inner.clone() };
674                        Ok(VirtioBalloonRequest::NotifyQueue { queue: req.queue, control_handle })
675                    }
676                    0x45707654f5d23c3f => {
677                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
678                        let mut req = fidl::new_empty!(
679                            VirtioDeviceReadyRequest,
680                            fidl::encoding::DefaultFuchsiaResourceDialect
681                        );
682                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
683                        let control_handle =
684                            VirtioBalloonControlHandle { inner: this.inner.clone() };
685                        Ok(VirtioBalloonRequest::Ready {
686                            negotiated_features: req.negotiated_features,
687
688                            responder: VirtioBalloonReadyResponder {
689                                control_handle: std::mem::ManuallyDrop::new(control_handle),
690                                tx_id: header.tx_id,
691                            },
692                        })
693                    }
694                    0x26645282fddf6f46 => {
695                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
696                        let mut req = fidl::new_empty!(
697                            VirtioBalloonStartRequest,
698                            fidl::encoding::DefaultFuchsiaResourceDialect
699                        );
700                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioBalloonStartRequest>(&header, _body_bytes, handles, &mut req)?;
701                        let control_handle =
702                            VirtioBalloonControlHandle { inner: this.inner.clone() };
703                        Ok(VirtioBalloonRequest::Start {
704                            start_info: req.start_info,
705
706                            responder: VirtioBalloonStartResponder {
707                                control_handle: std::mem::ManuallyDrop::new(control_handle),
708                                tx_id: header.tx_id,
709                            },
710                        })
711                    }
712                    0x6641f4c296607e24 => {
713                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
714                        let mut req = fidl::new_empty!(
715                            fidl::encoding::EmptyPayload,
716                            fidl::encoding::DefaultFuchsiaResourceDialect
717                        );
718                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
719                        let control_handle =
720                            VirtioBalloonControlHandle { inner: this.inner.clone() };
721                        Ok(VirtioBalloonRequest::GetMemStats {
722                            responder: VirtioBalloonGetMemStatsResponder {
723                                control_handle: std::mem::ManuallyDrop::new(control_handle),
724                                tx_id: header.tx_id,
725                            },
726                        })
727                    }
728                    _ => Err(fidl::Error::UnknownOrdinal {
729                        ordinal: header.ordinal,
730                        protocol_name:
731                            <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
732                    }),
733                }))
734            },
735        )
736    }
737}
738
739#[derive(Debug)]
740pub enum VirtioBalloonRequest {
741    /// Configure a `queue` for the device. This specifies the `size` and the
742    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
743    ConfigureQueue {
744        queue: u16,
745        size: u16,
746        desc: u64,
747        avail: u64,
748        used: u64,
749        responder: VirtioBalloonConfigureQueueResponder,
750    },
751    /// Notify a `queue` for the device. Primarily used for black-box testing.
752    NotifyQueue { queue: u16, control_handle: VirtioBalloonControlHandle },
753    /// Ready a device. This provides the set of `negotiated_features` that the
754    /// driver and device have agreed upon.
755    Ready { negotiated_features: u32, responder: VirtioBalloonReadyResponder },
756    /// Start the balloon device.
757    Start { start_info: StartInfo, responder: VirtioBalloonStartResponder },
758    /// Get memory statistics from the balloon device.
759    GetMemStats { responder: VirtioBalloonGetMemStatsResponder },
760}
761
762impl VirtioBalloonRequest {
763    #[allow(irrefutable_let_patterns)]
764    pub fn into_configure_queue(
765        self,
766    ) -> Option<(u16, u16, u64, u64, u64, VirtioBalloonConfigureQueueResponder)> {
767        if let VirtioBalloonRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
768            self
769        {
770            Some((queue, size, desc, avail, used, responder))
771        } else {
772            None
773        }
774    }
775
776    #[allow(irrefutable_let_patterns)]
777    pub fn into_notify_queue(self) -> Option<(u16, VirtioBalloonControlHandle)> {
778        if let VirtioBalloonRequest::NotifyQueue { queue, control_handle } = self {
779            Some((queue, control_handle))
780        } else {
781            None
782        }
783    }
784
785    #[allow(irrefutable_let_patterns)]
786    pub fn into_ready(self) -> Option<(u32, VirtioBalloonReadyResponder)> {
787        if let VirtioBalloonRequest::Ready { negotiated_features, responder } = self {
788            Some((negotiated_features, responder))
789        } else {
790            None
791        }
792    }
793
794    #[allow(irrefutable_let_patterns)]
795    pub fn into_start(self) -> Option<(StartInfo, VirtioBalloonStartResponder)> {
796        if let VirtioBalloonRequest::Start { start_info, responder } = self {
797            Some((start_info, responder))
798        } else {
799            None
800        }
801    }
802
803    #[allow(irrefutable_let_patterns)]
804    pub fn into_get_mem_stats(self) -> Option<(VirtioBalloonGetMemStatsResponder)> {
805        if let VirtioBalloonRequest::GetMemStats { responder } = self {
806            Some((responder))
807        } else {
808            None
809        }
810    }
811
812    /// Name of the method defined in FIDL
813    pub fn method_name(&self) -> &'static str {
814        match *self {
815            VirtioBalloonRequest::ConfigureQueue { .. } => "configure_queue",
816            VirtioBalloonRequest::NotifyQueue { .. } => "notify_queue",
817            VirtioBalloonRequest::Ready { .. } => "ready",
818            VirtioBalloonRequest::Start { .. } => "start",
819            VirtioBalloonRequest::GetMemStats { .. } => "get_mem_stats",
820        }
821    }
822}
823
824#[derive(Debug, Clone)]
825pub struct VirtioBalloonControlHandle {
826    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
827}
828
829impl fidl::endpoints::ControlHandle for VirtioBalloonControlHandle {
830    fn shutdown(&self) {
831        self.inner.shutdown()
832    }
833
834    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
835        self.inner.shutdown_with_epitaph(status)
836    }
837
838    fn is_closed(&self) -> bool {
839        self.inner.channel().is_closed()
840    }
841    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
842        self.inner.channel().on_closed()
843    }
844
845    #[cfg(target_os = "fuchsia")]
846    fn signal_peer(
847        &self,
848        clear_mask: zx::Signals,
849        set_mask: zx::Signals,
850    ) -> Result<(), zx_status::Status> {
851        use fidl::Peered;
852        self.inner.channel().signal_peer(clear_mask, set_mask)
853    }
854}
855
856impl VirtioBalloonControlHandle {}
857
858#[must_use = "FIDL methods require a response to be sent"]
859#[derive(Debug)]
860pub struct VirtioBalloonConfigureQueueResponder {
861    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
862    tx_id: u32,
863}
864
865/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
866/// if the responder is dropped without sending a response, so that the client
867/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
868impl std::ops::Drop for VirtioBalloonConfigureQueueResponder {
869    fn drop(&mut self) {
870        self.control_handle.shutdown();
871        // Safety: drops once, never accessed again
872        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
873    }
874}
875
876impl fidl::endpoints::Responder for VirtioBalloonConfigureQueueResponder {
877    type ControlHandle = VirtioBalloonControlHandle;
878
879    fn control_handle(&self) -> &VirtioBalloonControlHandle {
880        &self.control_handle
881    }
882
883    fn drop_without_shutdown(mut self) {
884        // Safety: drops once, never accessed again due to mem::forget
885        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
886        // Prevent Drop from running (which would shut down the channel)
887        std::mem::forget(self);
888    }
889}
890
891impl VirtioBalloonConfigureQueueResponder {
892    /// Sends a response to the FIDL transaction.
893    ///
894    /// Sets the channel to shutdown if an error occurs.
895    pub fn send(self) -> Result<(), fidl::Error> {
896        let _result = self.send_raw();
897        if _result.is_err() {
898            self.control_handle.shutdown();
899        }
900        self.drop_without_shutdown();
901        _result
902    }
903
904    /// Similar to "send" but does not shutdown the channel if an error occurs.
905    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
906        let _result = self.send_raw();
907        self.drop_without_shutdown();
908        _result
909    }
910
911    fn send_raw(&self) -> Result<(), fidl::Error> {
912        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
913            (),
914            self.tx_id,
915            0x72b44fb963480b11,
916            fidl::encoding::DynamicFlags::empty(),
917        )
918    }
919}
920
921#[must_use = "FIDL methods require a response to be sent"]
922#[derive(Debug)]
923pub struct VirtioBalloonReadyResponder {
924    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
925    tx_id: u32,
926}
927
928/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
929/// if the responder is dropped without sending a response, so that the client
930/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
931impl std::ops::Drop for VirtioBalloonReadyResponder {
932    fn drop(&mut self) {
933        self.control_handle.shutdown();
934        // Safety: drops once, never accessed again
935        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
936    }
937}
938
939impl fidl::endpoints::Responder for VirtioBalloonReadyResponder {
940    type ControlHandle = VirtioBalloonControlHandle;
941
942    fn control_handle(&self) -> &VirtioBalloonControlHandle {
943        &self.control_handle
944    }
945
946    fn drop_without_shutdown(mut self) {
947        // Safety: drops once, never accessed again due to mem::forget
948        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
949        // Prevent Drop from running (which would shut down the channel)
950        std::mem::forget(self);
951    }
952}
953
954impl VirtioBalloonReadyResponder {
955    /// Sends a response to the FIDL transaction.
956    ///
957    /// Sets the channel to shutdown if an error occurs.
958    pub fn send(self) -> Result<(), fidl::Error> {
959        let _result = self.send_raw();
960        if _result.is_err() {
961            self.control_handle.shutdown();
962        }
963        self.drop_without_shutdown();
964        _result
965    }
966
967    /// Similar to "send" but does not shutdown the channel if an error occurs.
968    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
969        let _result = self.send_raw();
970        self.drop_without_shutdown();
971        _result
972    }
973
974    fn send_raw(&self) -> Result<(), fidl::Error> {
975        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
976            (),
977            self.tx_id,
978            0x45707654f5d23c3f,
979            fidl::encoding::DynamicFlags::empty(),
980        )
981    }
982}
983
984#[must_use = "FIDL methods require a response to be sent"]
985#[derive(Debug)]
986pub struct VirtioBalloonStartResponder {
987    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
988    tx_id: u32,
989}
990
991/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
992/// if the responder is dropped without sending a response, so that the client
993/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
994impl std::ops::Drop for VirtioBalloonStartResponder {
995    fn drop(&mut self) {
996        self.control_handle.shutdown();
997        // Safety: drops once, never accessed again
998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
999    }
1000}
1001
1002impl fidl::endpoints::Responder for VirtioBalloonStartResponder {
1003    type ControlHandle = VirtioBalloonControlHandle;
1004
1005    fn control_handle(&self) -> &VirtioBalloonControlHandle {
1006        &self.control_handle
1007    }
1008
1009    fn drop_without_shutdown(mut self) {
1010        // Safety: drops once, never accessed again due to mem::forget
1011        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1012        // Prevent Drop from running (which would shut down the channel)
1013        std::mem::forget(self);
1014    }
1015}
1016
1017impl VirtioBalloonStartResponder {
1018    /// Sends a response to the FIDL transaction.
1019    ///
1020    /// Sets the channel to shutdown if an error occurs.
1021    pub fn send(self) -> Result<(), fidl::Error> {
1022        let _result = self.send_raw();
1023        if _result.is_err() {
1024            self.control_handle.shutdown();
1025        }
1026        self.drop_without_shutdown();
1027        _result
1028    }
1029
1030    /// Similar to "send" but does not shutdown the channel if an error occurs.
1031    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1032        let _result = self.send_raw();
1033        self.drop_without_shutdown();
1034        _result
1035    }
1036
1037    fn send_raw(&self) -> Result<(), fidl::Error> {
1038        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1039            (),
1040            self.tx_id,
1041            0x26645282fddf6f46,
1042            fidl::encoding::DynamicFlags::empty(),
1043        )
1044    }
1045}
1046
1047#[must_use = "FIDL methods require a response to be sent"]
1048#[derive(Debug)]
1049pub struct VirtioBalloonGetMemStatsResponder {
1050    control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
1051    tx_id: u32,
1052}
1053
1054/// Set the the channel to be shutdown (see [`VirtioBalloonControlHandle::shutdown`])
1055/// if the responder is dropped without sending a response, so that the client
1056/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1057impl std::ops::Drop for VirtioBalloonGetMemStatsResponder {
1058    fn drop(&mut self) {
1059        self.control_handle.shutdown();
1060        // Safety: drops once, never accessed again
1061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1062    }
1063}
1064
1065impl fidl::endpoints::Responder for VirtioBalloonGetMemStatsResponder {
1066    type ControlHandle = VirtioBalloonControlHandle;
1067
1068    fn control_handle(&self) -> &VirtioBalloonControlHandle {
1069        &self.control_handle
1070    }
1071
1072    fn drop_without_shutdown(mut self) {
1073        // Safety: drops once, never accessed again due to mem::forget
1074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1075        // Prevent Drop from running (which would shut down the channel)
1076        std::mem::forget(self);
1077    }
1078}
1079
1080impl VirtioBalloonGetMemStatsResponder {
1081    /// Sends a response to the FIDL transaction.
1082    ///
1083    /// Sets the channel to shutdown if an error occurs.
1084    pub fn send(
1085        self,
1086        mut status: i32,
1087        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1088    ) -> Result<(), fidl::Error> {
1089        let _result = self.send_raw(status, mem_stats);
1090        if _result.is_err() {
1091            self.control_handle.shutdown();
1092        }
1093        self.drop_without_shutdown();
1094        _result
1095    }
1096
1097    /// Similar to "send" but does not shutdown the channel if an error occurs.
1098    pub fn send_no_shutdown_on_err(
1099        self,
1100        mut status: i32,
1101        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1102    ) -> Result<(), fidl::Error> {
1103        let _result = self.send_raw(status, mem_stats);
1104        self.drop_without_shutdown();
1105        _result
1106    }
1107
1108    fn send_raw(
1109        &self,
1110        mut status: i32,
1111        mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
1112    ) -> Result<(), fidl::Error> {
1113        self.control_handle.inner.send::<VirtioBalloonGetMemStatsResponse>(
1114            (status, mem_stats),
1115            self.tx_id,
1116            0x6641f4c296607e24,
1117            fidl::encoding::DynamicFlags::empty(),
1118        )
1119    }
1120}
1121
1122#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1123pub struct VirtioBlockMarker;
1124
1125impl fidl::endpoints::ProtocolMarker for VirtioBlockMarker {
1126    type Proxy = VirtioBlockProxy;
1127    type RequestStream = VirtioBlockRequestStream;
1128    #[cfg(target_os = "fuchsia")]
1129    type SynchronousProxy = VirtioBlockSynchronousProxy;
1130
1131    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioBlock";
1132}
1133impl fidl::endpoints::DiscoverableProtocolMarker for VirtioBlockMarker {}
1134
1135pub trait VirtioBlockProxyInterface: Send + Sync {
1136    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1137    fn r#configure_queue(
1138        &self,
1139        queue: u16,
1140        size: u16,
1141        desc: u64,
1142        avail: u64,
1143        used: u64,
1144    ) -> Self::ConfigureQueueResponseFut;
1145    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
1146    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1147    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
1148    type StartResponseFut: std::future::Future<Output = Result<(u64, u32), fidl::Error>> + Send;
1149    fn r#start(
1150        &self,
1151        start_info: StartInfo,
1152        spec: fidl_fuchsia_virtualization::BlockSpec,
1153    ) -> Self::StartResponseFut;
1154}
1155#[derive(Debug)]
1156#[cfg(target_os = "fuchsia")]
1157pub struct VirtioBlockSynchronousProxy {
1158    client: fidl::client::sync::Client,
1159}
1160
1161#[cfg(target_os = "fuchsia")]
1162impl fidl::endpoints::SynchronousProxy for VirtioBlockSynchronousProxy {
1163    type Proxy = VirtioBlockProxy;
1164    type Protocol = VirtioBlockMarker;
1165
1166    fn from_channel(inner: fidl::Channel) -> Self {
1167        Self::new(inner)
1168    }
1169
1170    fn into_channel(self) -> fidl::Channel {
1171        self.client.into_channel()
1172    }
1173
1174    fn as_channel(&self) -> &fidl::Channel {
1175        self.client.as_channel()
1176    }
1177}
1178
1179#[cfg(target_os = "fuchsia")]
1180impl VirtioBlockSynchronousProxy {
1181    pub fn new(channel: fidl::Channel) -> Self {
1182        Self { client: fidl::client::sync::Client::new(channel) }
1183    }
1184
1185    pub fn into_channel(self) -> fidl::Channel {
1186        self.client.into_channel()
1187    }
1188
1189    /// Waits until an event arrives and returns it. It is safe for other
1190    /// threads to make concurrent requests while waiting for an event.
1191    pub fn wait_for_event(
1192        &self,
1193        deadline: zx::MonotonicInstant,
1194    ) -> Result<VirtioBlockEvent, fidl::Error> {
1195        VirtioBlockEvent::decode(self.client.wait_for_event::<VirtioBlockMarker>(deadline)?)
1196    }
1197
1198    /// Configure a `queue` for the device. This specifies the `size` and the
1199    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1200    pub fn r#configure_queue(
1201        &self,
1202        mut queue: u16,
1203        mut size: u16,
1204        mut desc: u64,
1205        mut avail: u64,
1206        mut used: u64,
1207        ___deadline: zx::MonotonicInstant,
1208    ) -> Result<(), fidl::Error> {
1209        let _response = self.client.send_query::<
1210            VirtioDeviceConfigureQueueRequest,
1211            fidl::encoding::EmptyPayload,
1212            VirtioBlockMarker,
1213        >(
1214            (queue, size, desc, avail, used,),
1215            0x72b44fb963480b11,
1216            fidl::encoding::DynamicFlags::empty(),
1217            ___deadline,
1218        )?;
1219        Ok(_response)
1220    }
1221
1222    /// Notify a `queue` for the device. Primarily used for black-box testing.
1223    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1224        self.client.send::<VirtioDeviceNotifyQueueRequest>(
1225            (queue,),
1226            0x6e3a61d652499244,
1227            fidl::encoding::DynamicFlags::empty(),
1228        )
1229    }
1230
1231    /// Ready a device. This provides the set of `negotiated_features` that the
1232    /// driver and device have agreed upon.
1233    pub fn r#ready(
1234        &self,
1235        mut negotiated_features: u32,
1236        ___deadline: zx::MonotonicInstant,
1237    ) -> Result<(), fidl::Error> {
1238        let _response = self.client.send_query::<
1239            VirtioDeviceReadyRequest,
1240            fidl::encoding::EmptyPayload,
1241            VirtioBlockMarker,
1242        >(
1243            (negotiated_features,),
1244            0x45707654f5d23c3f,
1245            fidl::encoding::DynamicFlags::empty(),
1246            ___deadline,
1247        )?;
1248        Ok(_response)
1249    }
1250
1251    /// Start the block device.
1252    pub fn r#start(
1253        &self,
1254        mut start_info: StartInfo,
1255        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1256        ___deadline: zx::MonotonicInstant,
1257    ) -> Result<(u64, u32), fidl::Error> {
1258        let _response = self
1259            .client
1260            .send_query::<VirtioBlockStartRequest, VirtioBlockStartResponse, VirtioBlockMarker>(
1261                (&mut start_info, &mut spec),
1262                0x5ef6a4b9ce9adcb2,
1263                fidl::encoding::DynamicFlags::empty(),
1264                ___deadline,
1265            )?;
1266        Ok((_response.capacity, _response.block_size))
1267    }
1268}
1269
1270#[cfg(target_os = "fuchsia")]
1271impl From<VirtioBlockSynchronousProxy> for zx::NullableHandle {
1272    fn from(value: VirtioBlockSynchronousProxy) -> Self {
1273        value.into_channel().into()
1274    }
1275}
1276
1277#[cfg(target_os = "fuchsia")]
1278impl From<fidl::Channel> for VirtioBlockSynchronousProxy {
1279    fn from(value: fidl::Channel) -> Self {
1280        Self::new(value)
1281    }
1282}
1283
1284#[cfg(target_os = "fuchsia")]
1285impl fidl::endpoints::FromClient for VirtioBlockSynchronousProxy {
1286    type Protocol = VirtioBlockMarker;
1287
1288    fn from_client(value: fidl::endpoints::ClientEnd<VirtioBlockMarker>) -> Self {
1289        Self::new(value.into_channel())
1290    }
1291}
1292
1293#[derive(Debug, Clone)]
1294pub struct VirtioBlockProxy {
1295    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1296}
1297
1298impl fidl::endpoints::Proxy for VirtioBlockProxy {
1299    type Protocol = VirtioBlockMarker;
1300
1301    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1302        Self::new(inner)
1303    }
1304
1305    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1306        self.client.into_channel().map_err(|client| Self { client })
1307    }
1308
1309    fn as_channel(&self) -> &::fidl::AsyncChannel {
1310        self.client.as_channel()
1311    }
1312}
1313
1314impl VirtioBlockProxy {
1315    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioBlock.
1316    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1317        let protocol_name = <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1318        Self { client: fidl::client::Client::new(channel, protocol_name) }
1319    }
1320
1321    /// Get a Stream of events from the remote end of the protocol.
1322    ///
1323    /// # Panics
1324    ///
1325    /// Panics if the event stream was already taken.
1326    pub fn take_event_stream(&self) -> VirtioBlockEventStream {
1327        VirtioBlockEventStream { event_receiver: self.client.take_event_receiver() }
1328    }
1329
1330    /// Configure a `queue` for the device. This specifies the `size` and the
1331    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1332    pub fn r#configure_queue(
1333        &self,
1334        mut queue: u16,
1335        mut size: u16,
1336        mut desc: u64,
1337        mut avail: u64,
1338        mut used: u64,
1339    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1340        VirtioBlockProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
1341    }
1342
1343    /// Notify a `queue` for the device. Primarily used for black-box testing.
1344    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1345        VirtioBlockProxyInterface::r#notify_queue(self, queue)
1346    }
1347
1348    /// Ready a device. This provides the set of `negotiated_features` that the
1349    /// driver and device have agreed upon.
1350    pub fn r#ready(
1351        &self,
1352        mut negotiated_features: u32,
1353    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1354        VirtioBlockProxyInterface::r#ready(self, negotiated_features)
1355    }
1356
1357    /// Start the block device.
1358    pub fn r#start(
1359        &self,
1360        mut start_info: StartInfo,
1361        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1362    ) -> fidl::client::QueryResponseFut<(u64, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
1363    {
1364        VirtioBlockProxyInterface::r#start(self, start_info, spec)
1365    }
1366}
1367
1368impl VirtioBlockProxyInterface for VirtioBlockProxy {
1369    type ConfigureQueueResponseFut =
1370        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1371    fn r#configure_queue(
1372        &self,
1373        mut queue: u16,
1374        mut size: u16,
1375        mut desc: u64,
1376        mut avail: u64,
1377        mut used: u64,
1378    ) -> Self::ConfigureQueueResponseFut {
1379        fn _decode(
1380            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1381        ) -> Result<(), fidl::Error> {
1382            let _response = fidl::client::decode_transaction_body::<
1383                fidl::encoding::EmptyPayload,
1384                fidl::encoding::DefaultFuchsiaResourceDialect,
1385                0x72b44fb963480b11,
1386            >(_buf?)?;
1387            Ok(_response)
1388        }
1389        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
1390            (queue, size, desc, avail, used),
1391            0x72b44fb963480b11,
1392            fidl::encoding::DynamicFlags::empty(),
1393            _decode,
1394        )
1395    }
1396
1397    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
1398        self.client.send::<VirtioDeviceNotifyQueueRequest>(
1399            (queue,),
1400            0x6e3a61d652499244,
1401            fidl::encoding::DynamicFlags::empty(),
1402        )
1403    }
1404
1405    type ReadyResponseFut =
1406        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1407    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
1408        fn _decode(
1409            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1410        ) -> Result<(), fidl::Error> {
1411            let _response = fidl::client::decode_transaction_body::<
1412                fidl::encoding::EmptyPayload,
1413                fidl::encoding::DefaultFuchsiaResourceDialect,
1414                0x45707654f5d23c3f,
1415            >(_buf?)?;
1416            Ok(_response)
1417        }
1418        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
1419            (negotiated_features,),
1420            0x45707654f5d23c3f,
1421            fidl::encoding::DynamicFlags::empty(),
1422            _decode,
1423        )
1424    }
1425
1426    type StartResponseFut =
1427        fidl::client::QueryResponseFut<(u64, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
1428    fn r#start(
1429        &self,
1430        mut start_info: StartInfo,
1431        mut spec: fidl_fuchsia_virtualization::BlockSpec,
1432    ) -> Self::StartResponseFut {
1433        fn _decode(
1434            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1435        ) -> Result<(u64, u32), fidl::Error> {
1436            let _response = fidl::client::decode_transaction_body::<
1437                VirtioBlockStartResponse,
1438                fidl::encoding::DefaultFuchsiaResourceDialect,
1439                0x5ef6a4b9ce9adcb2,
1440            >(_buf?)?;
1441            Ok((_response.capacity, _response.block_size))
1442        }
1443        self.client.send_query_and_decode::<VirtioBlockStartRequest, (u64, u32)>(
1444            (&mut start_info, &mut spec),
1445            0x5ef6a4b9ce9adcb2,
1446            fidl::encoding::DynamicFlags::empty(),
1447            _decode,
1448        )
1449    }
1450}
1451
1452pub struct VirtioBlockEventStream {
1453    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1454}
1455
1456impl std::marker::Unpin for VirtioBlockEventStream {}
1457
1458impl futures::stream::FusedStream for VirtioBlockEventStream {
1459    fn is_terminated(&self) -> bool {
1460        self.event_receiver.is_terminated()
1461    }
1462}
1463
1464impl futures::Stream for VirtioBlockEventStream {
1465    type Item = Result<VirtioBlockEvent, fidl::Error>;
1466
1467    fn poll_next(
1468        mut self: std::pin::Pin<&mut Self>,
1469        cx: &mut std::task::Context<'_>,
1470    ) -> std::task::Poll<Option<Self::Item>> {
1471        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1472            &mut self.event_receiver,
1473            cx
1474        )?) {
1475            Some(buf) => std::task::Poll::Ready(Some(VirtioBlockEvent::decode(buf))),
1476            None => std::task::Poll::Ready(None),
1477        }
1478    }
1479}
1480
1481#[derive(Debug)]
1482pub enum VirtioBlockEvent {}
1483
1484impl VirtioBlockEvent {
1485    /// Decodes a message buffer as a [`VirtioBlockEvent`].
1486    fn decode(
1487        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1488    ) -> Result<VirtioBlockEvent, fidl::Error> {
1489        let (bytes, _handles) = buf.split_mut();
1490        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1491        debug_assert_eq!(tx_header.tx_id, 0);
1492        match tx_header.ordinal {
1493            _ => Err(fidl::Error::UnknownOrdinal {
1494                ordinal: tx_header.ordinal,
1495                protocol_name: <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1496            }),
1497        }
1498    }
1499}
1500
1501/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioBlock.
1502pub struct VirtioBlockRequestStream {
1503    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1504    is_terminated: bool,
1505}
1506
1507impl std::marker::Unpin for VirtioBlockRequestStream {}
1508
1509impl futures::stream::FusedStream for VirtioBlockRequestStream {
1510    fn is_terminated(&self) -> bool {
1511        self.is_terminated
1512    }
1513}
1514
1515impl fidl::endpoints::RequestStream for VirtioBlockRequestStream {
1516    type Protocol = VirtioBlockMarker;
1517    type ControlHandle = VirtioBlockControlHandle;
1518
1519    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1520        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1521    }
1522
1523    fn control_handle(&self) -> Self::ControlHandle {
1524        VirtioBlockControlHandle { inner: self.inner.clone() }
1525    }
1526
1527    fn into_inner(
1528        self,
1529    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1530    {
1531        (self.inner, self.is_terminated)
1532    }
1533
1534    fn from_inner(
1535        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1536        is_terminated: bool,
1537    ) -> Self {
1538        Self { inner, is_terminated }
1539    }
1540}
1541
1542impl futures::Stream for VirtioBlockRequestStream {
1543    type Item = Result<VirtioBlockRequest, fidl::Error>;
1544
1545    fn poll_next(
1546        mut self: std::pin::Pin<&mut Self>,
1547        cx: &mut std::task::Context<'_>,
1548    ) -> std::task::Poll<Option<Self::Item>> {
1549        let this = &mut *self;
1550        if this.inner.check_shutdown(cx) {
1551            this.is_terminated = true;
1552            return std::task::Poll::Ready(None);
1553        }
1554        if this.is_terminated {
1555            panic!("polled VirtioBlockRequestStream after completion");
1556        }
1557        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1558            |bytes, handles| {
1559                match this.inner.channel().read_etc(cx, bytes, handles) {
1560                    std::task::Poll::Ready(Ok(())) => {}
1561                    std::task::Poll::Pending => return std::task::Poll::Pending,
1562                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1563                        this.is_terminated = true;
1564                        return std::task::Poll::Ready(None);
1565                    }
1566                    std::task::Poll::Ready(Err(e)) => {
1567                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1568                            e.into(),
1569                        ))));
1570                    }
1571                }
1572
1573                // A message has been received from the channel
1574                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1575
1576                std::task::Poll::Ready(Some(match header.ordinal {
1577                    0x72b44fb963480b11 => {
1578                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1579                        let mut req = fidl::new_empty!(
1580                            VirtioDeviceConfigureQueueRequest,
1581                            fidl::encoding::DefaultFuchsiaResourceDialect
1582                        );
1583                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
1584                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1585                        Ok(VirtioBlockRequest::ConfigureQueue {
1586                            queue: req.queue,
1587                            size: req.size,
1588                            desc: req.desc,
1589                            avail: req.avail,
1590                            used: req.used,
1591
1592                            responder: VirtioBlockConfigureQueueResponder {
1593                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1594                                tx_id: header.tx_id,
1595                            },
1596                        })
1597                    }
1598                    0x6e3a61d652499244 => {
1599                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1600                        let mut req = fidl::new_empty!(
1601                            VirtioDeviceNotifyQueueRequest,
1602                            fidl::encoding::DefaultFuchsiaResourceDialect
1603                        );
1604                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
1605                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1606                        Ok(VirtioBlockRequest::NotifyQueue { queue: req.queue, control_handle })
1607                    }
1608                    0x45707654f5d23c3f => {
1609                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1610                        let mut req = fidl::new_empty!(
1611                            VirtioDeviceReadyRequest,
1612                            fidl::encoding::DefaultFuchsiaResourceDialect
1613                        );
1614                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
1615                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1616                        Ok(VirtioBlockRequest::Ready {
1617                            negotiated_features: req.negotiated_features,
1618
1619                            responder: VirtioBlockReadyResponder {
1620                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1621                                tx_id: header.tx_id,
1622                            },
1623                        })
1624                    }
1625                    0x5ef6a4b9ce9adcb2 => {
1626                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1627                        let mut req = fidl::new_empty!(
1628                            VirtioBlockStartRequest,
1629                            fidl::encoding::DefaultFuchsiaResourceDialect
1630                        );
1631                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioBlockStartRequest>(&header, _body_bytes, handles, &mut req)?;
1632                        let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
1633                        Ok(VirtioBlockRequest::Start {
1634                            start_info: req.start_info,
1635                            spec: req.spec,
1636
1637                            responder: VirtioBlockStartResponder {
1638                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1639                                tx_id: header.tx_id,
1640                            },
1641                        })
1642                    }
1643                    _ => Err(fidl::Error::UnknownOrdinal {
1644                        ordinal: header.ordinal,
1645                        protocol_name:
1646                            <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1647                    }),
1648                }))
1649            },
1650        )
1651    }
1652}
1653
1654#[derive(Debug)]
1655pub enum VirtioBlockRequest {
1656    /// Configure a `queue` for the device. This specifies the `size` and the
1657    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
1658    ConfigureQueue {
1659        queue: u16,
1660        size: u16,
1661        desc: u64,
1662        avail: u64,
1663        used: u64,
1664        responder: VirtioBlockConfigureQueueResponder,
1665    },
1666    /// Notify a `queue` for the device. Primarily used for black-box testing.
1667    NotifyQueue { queue: u16, control_handle: VirtioBlockControlHandle },
1668    /// Ready a device. This provides the set of `negotiated_features` that the
1669    /// driver and device have agreed upon.
1670    Ready { negotiated_features: u32, responder: VirtioBlockReadyResponder },
1671    /// Start the block device.
1672    Start {
1673        start_info: StartInfo,
1674        spec: fidl_fuchsia_virtualization::BlockSpec,
1675        responder: VirtioBlockStartResponder,
1676    },
1677}
1678
1679impl VirtioBlockRequest {
1680    #[allow(irrefutable_let_patterns)]
1681    pub fn into_configure_queue(
1682        self,
1683    ) -> Option<(u16, u16, u64, u64, u64, VirtioBlockConfigureQueueResponder)> {
1684        if let VirtioBlockRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
1685            self
1686        {
1687            Some((queue, size, desc, avail, used, responder))
1688        } else {
1689            None
1690        }
1691    }
1692
1693    #[allow(irrefutable_let_patterns)]
1694    pub fn into_notify_queue(self) -> Option<(u16, VirtioBlockControlHandle)> {
1695        if let VirtioBlockRequest::NotifyQueue { queue, control_handle } = self {
1696            Some((queue, control_handle))
1697        } else {
1698            None
1699        }
1700    }
1701
1702    #[allow(irrefutable_let_patterns)]
1703    pub fn into_ready(self) -> Option<(u32, VirtioBlockReadyResponder)> {
1704        if let VirtioBlockRequest::Ready { negotiated_features, responder } = self {
1705            Some((negotiated_features, responder))
1706        } else {
1707            None
1708        }
1709    }
1710
1711    #[allow(irrefutable_let_patterns)]
1712    pub fn into_start(
1713        self,
1714    ) -> Option<(StartInfo, fidl_fuchsia_virtualization::BlockSpec, VirtioBlockStartResponder)>
1715    {
1716        if let VirtioBlockRequest::Start { start_info, spec, responder } = self {
1717            Some((start_info, spec, responder))
1718        } else {
1719            None
1720        }
1721    }
1722
1723    /// Name of the method defined in FIDL
1724    pub fn method_name(&self) -> &'static str {
1725        match *self {
1726            VirtioBlockRequest::ConfigureQueue { .. } => "configure_queue",
1727            VirtioBlockRequest::NotifyQueue { .. } => "notify_queue",
1728            VirtioBlockRequest::Ready { .. } => "ready",
1729            VirtioBlockRequest::Start { .. } => "start",
1730        }
1731    }
1732}
1733
1734#[derive(Debug, Clone)]
1735pub struct VirtioBlockControlHandle {
1736    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1737}
1738
1739impl fidl::endpoints::ControlHandle for VirtioBlockControlHandle {
1740    fn shutdown(&self) {
1741        self.inner.shutdown()
1742    }
1743
1744    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1745        self.inner.shutdown_with_epitaph(status)
1746    }
1747
1748    fn is_closed(&self) -> bool {
1749        self.inner.channel().is_closed()
1750    }
1751    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1752        self.inner.channel().on_closed()
1753    }
1754
1755    #[cfg(target_os = "fuchsia")]
1756    fn signal_peer(
1757        &self,
1758        clear_mask: zx::Signals,
1759        set_mask: zx::Signals,
1760    ) -> Result<(), zx_status::Status> {
1761        use fidl::Peered;
1762        self.inner.channel().signal_peer(clear_mask, set_mask)
1763    }
1764}
1765
1766impl VirtioBlockControlHandle {}
1767
1768#[must_use = "FIDL methods require a response to be sent"]
1769#[derive(Debug)]
1770pub struct VirtioBlockConfigureQueueResponder {
1771    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1772    tx_id: u32,
1773}
1774
1775/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1776/// if the responder is dropped without sending a response, so that the client
1777/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1778impl std::ops::Drop for VirtioBlockConfigureQueueResponder {
1779    fn drop(&mut self) {
1780        self.control_handle.shutdown();
1781        // Safety: drops once, never accessed again
1782        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1783    }
1784}
1785
1786impl fidl::endpoints::Responder for VirtioBlockConfigureQueueResponder {
1787    type ControlHandle = VirtioBlockControlHandle;
1788
1789    fn control_handle(&self) -> &VirtioBlockControlHandle {
1790        &self.control_handle
1791    }
1792
1793    fn drop_without_shutdown(mut self) {
1794        // Safety: drops once, never accessed again due to mem::forget
1795        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1796        // Prevent Drop from running (which would shut down the channel)
1797        std::mem::forget(self);
1798    }
1799}
1800
1801impl VirtioBlockConfigureQueueResponder {
1802    /// Sends a response to the FIDL transaction.
1803    ///
1804    /// Sets the channel to shutdown if an error occurs.
1805    pub fn send(self) -> Result<(), fidl::Error> {
1806        let _result = self.send_raw();
1807        if _result.is_err() {
1808            self.control_handle.shutdown();
1809        }
1810        self.drop_without_shutdown();
1811        _result
1812    }
1813
1814    /// Similar to "send" but does not shutdown the channel if an error occurs.
1815    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1816        let _result = self.send_raw();
1817        self.drop_without_shutdown();
1818        _result
1819    }
1820
1821    fn send_raw(&self) -> Result<(), fidl::Error> {
1822        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1823            (),
1824            self.tx_id,
1825            0x72b44fb963480b11,
1826            fidl::encoding::DynamicFlags::empty(),
1827        )
1828    }
1829}
1830
1831#[must_use = "FIDL methods require a response to be sent"]
1832#[derive(Debug)]
1833pub struct VirtioBlockReadyResponder {
1834    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1835    tx_id: u32,
1836}
1837
1838/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1839/// if the responder is dropped without sending a response, so that the client
1840/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1841impl std::ops::Drop for VirtioBlockReadyResponder {
1842    fn drop(&mut self) {
1843        self.control_handle.shutdown();
1844        // Safety: drops once, never accessed again
1845        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1846    }
1847}
1848
1849impl fidl::endpoints::Responder for VirtioBlockReadyResponder {
1850    type ControlHandle = VirtioBlockControlHandle;
1851
1852    fn control_handle(&self) -> &VirtioBlockControlHandle {
1853        &self.control_handle
1854    }
1855
1856    fn drop_without_shutdown(mut self) {
1857        // Safety: drops once, never accessed again due to mem::forget
1858        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1859        // Prevent Drop from running (which would shut down the channel)
1860        std::mem::forget(self);
1861    }
1862}
1863
1864impl VirtioBlockReadyResponder {
1865    /// Sends a response to the FIDL transaction.
1866    ///
1867    /// Sets the channel to shutdown if an error occurs.
1868    pub fn send(self) -> Result<(), fidl::Error> {
1869        let _result = self.send_raw();
1870        if _result.is_err() {
1871            self.control_handle.shutdown();
1872        }
1873        self.drop_without_shutdown();
1874        _result
1875    }
1876
1877    /// Similar to "send" but does not shutdown the channel if an error occurs.
1878    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1879        let _result = self.send_raw();
1880        self.drop_without_shutdown();
1881        _result
1882    }
1883
1884    fn send_raw(&self) -> Result<(), fidl::Error> {
1885        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1886            (),
1887            self.tx_id,
1888            0x45707654f5d23c3f,
1889            fidl::encoding::DynamicFlags::empty(),
1890        )
1891    }
1892}
1893
1894#[must_use = "FIDL methods require a response to be sent"]
1895#[derive(Debug)]
1896pub struct VirtioBlockStartResponder {
1897    control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
1898    tx_id: u32,
1899}
1900
1901/// Set the the channel to be shutdown (see [`VirtioBlockControlHandle::shutdown`])
1902/// if the responder is dropped without sending a response, so that the client
1903/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1904impl std::ops::Drop for VirtioBlockStartResponder {
1905    fn drop(&mut self) {
1906        self.control_handle.shutdown();
1907        // Safety: drops once, never accessed again
1908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1909    }
1910}
1911
1912impl fidl::endpoints::Responder for VirtioBlockStartResponder {
1913    type ControlHandle = VirtioBlockControlHandle;
1914
1915    fn control_handle(&self) -> &VirtioBlockControlHandle {
1916        &self.control_handle
1917    }
1918
1919    fn drop_without_shutdown(mut self) {
1920        // Safety: drops once, never accessed again due to mem::forget
1921        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1922        // Prevent Drop from running (which would shut down the channel)
1923        std::mem::forget(self);
1924    }
1925}
1926
1927impl VirtioBlockStartResponder {
1928    /// Sends a response to the FIDL transaction.
1929    ///
1930    /// Sets the channel to shutdown if an error occurs.
1931    pub fn send(self, mut capacity: u64, mut block_size: u32) -> Result<(), fidl::Error> {
1932        let _result = self.send_raw(capacity, block_size);
1933        if _result.is_err() {
1934            self.control_handle.shutdown();
1935        }
1936        self.drop_without_shutdown();
1937        _result
1938    }
1939
1940    /// Similar to "send" but does not shutdown the channel if an error occurs.
1941    pub fn send_no_shutdown_on_err(
1942        self,
1943        mut capacity: u64,
1944        mut block_size: u32,
1945    ) -> Result<(), fidl::Error> {
1946        let _result = self.send_raw(capacity, block_size);
1947        self.drop_without_shutdown();
1948        _result
1949    }
1950
1951    fn send_raw(&self, mut capacity: u64, mut block_size: u32) -> Result<(), fidl::Error> {
1952        self.control_handle.inner.send::<VirtioBlockStartResponse>(
1953            (capacity, block_size),
1954            self.tx_id,
1955            0x5ef6a4b9ce9adcb2,
1956            fidl::encoding::DynamicFlags::empty(),
1957        )
1958    }
1959}
1960
1961#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1962pub struct VirtioConsoleMarker;
1963
1964impl fidl::endpoints::ProtocolMarker for VirtioConsoleMarker {
1965    type Proxy = VirtioConsoleProxy;
1966    type RequestStream = VirtioConsoleRequestStream;
1967    #[cfg(target_os = "fuchsia")]
1968    type SynchronousProxy = VirtioConsoleSynchronousProxy;
1969
1970    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioConsole";
1971}
1972impl fidl::endpoints::DiscoverableProtocolMarker for VirtioConsoleMarker {}
1973
1974pub trait VirtioConsoleProxyInterface: Send + Sync {
1975    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1976    fn r#configure_queue(
1977        &self,
1978        queue: u16,
1979        size: u16,
1980        desc: u64,
1981        avail: u64,
1982        used: u64,
1983    ) -> Self::ConfigureQueueResponseFut;
1984    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
1985    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1986    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
1987    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1988    fn r#start(&self, start_info: StartInfo, socket: fidl::Socket) -> Self::StartResponseFut;
1989}
1990#[derive(Debug)]
1991#[cfg(target_os = "fuchsia")]
1992pub struct VirtioConsoleSynchronousProxy {
1993    client: fidl::client::sync::Client,
1994}
1995
1996#[cfg(target_os = "fuchsia")]
1997impl fidl::endpoints::SynchronousProxy for VirtioConsoleSynchronousProxy {
1998    type Proxy = VirtioConsoleProxy;
1999    type Protocol = VirtioConsoleMarker;
2000
2001    fn from_channel(inner: fidl::Channel) -> Self {
2002        Self::new(inner)
2003    }
2004
2005    fn into_channel(self) -> fidl::Channel {
2006        self.client.into_channel()
2007    }
2008
2009    fn as_channel(&self) -> &fidl::Channel {
2010        self.client.as_channel()
2011    }
2012}
2013
2014#[cfg(target_os = "fuchsia")]
2015impl VirtioConsoleSynchronousProxy {
2016    pub fn new(channel: fidl::Channel) -> Self {
2017        Self { client: fidl::client::sync::Client::new(channel) }
2018    }
2019
2020    pub fn into_channel(self) -> fidl::Channel {
2021        self.client.into_channel()
2022    }
2023
2024    /// Waits until an event arrives and returns it. It is safe for other
2025    /// threads to make concurrent requests while waiting for an event.
2026    pub fn wait_for_event(
2027        &self,
2028        deadline: zx::MonotonicInstant,
2029    ) -> Result<VirtioConsoleEvent, fidl::Error> {
2030        VirtioConsoleEvent::decode(self.client.wait_for_event::<VirtioConsoleMarker>(deadline)?)
2031    }
2032
2033    /// Configure a `queue` for the device. This specifies the `size` and the
2034    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2035    pub fn r#configure_queue(
2036        &self,
2037        mut queue: u16,
2038        mut size: u16,
2039        mut desc: u64,
2040        mut avail: u64,
2041        mut used: u64,
2042        ___deadline: zx::MonotonicInstant,
2043    ) -> Result<(), fidl::Error> {
2044        let _response = self.client.send_query::<
2045            VirtioDeviceConfigureQueueRequest,
2046            fidl::encoding::EmptyPayload,
2047            VirtioConsoleMarker,
2048        >(
2049            (queue, size, desc, avail, used,),
2050            0x72b44fb963480b11,
2051            fidl::encoding::DynamicFlags::empty(),
2052            ___deadline,
2053        )?;
2054        Ok(_response)
2055    }
2056
2057    /// Notify a `queue` for the device. Primarily used for black-box testing.
2058    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2059        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2060            (queue,),
2061            0x6e3a61d652499244,
2062            fidl::encoding::DynamicFlags::empty(),
2063        )
2064    }
2065
2066    /// Ready a device. This provides the set of `negotiated_features` that the
2067    /// driver and device have agreed upon.
2068    pub fn r#ready(
2069        &self,
2070        mut negotiated_features: u32,
2071        ___deadline: zx::MonotonicInstant,
2072    ) -> Result<(), fidl::Error> {
2073        let _response = self.client.send_query::<
2074            VirtioDeviceReadyRequest,
2075            fidl::encoding::EmptyPayload,
2076            VirtioConsoleMarker,
2077        >(
2078            (negotiated_features,),
2079            0x45707654f5d23c3f,
2080            fidl::encoding::DynamicFlags::empty(),
2081            ___deadline,
2082        )?;
2083        Ok(_response)
2084    }
2085
2086    /// Start the console device. This uses `socket` to handle input and output.
2087    pub fn r#start(
2088        &self,
2089        mut start_info: StartInfo,
2090        mut socket: fidl::Socket,
2091        ___deadline: zx::MonotonicInstant,
2092    ) -> Result<(), fidl::Error> {
2093        let _response = self.client.send_query::<
2094            VirtioConsoleStartRequest,
2095            fidl::encoding::EmptyPayload,
2096            VirtioConsoleMarker,
2097        >(
2098            (&mut start_info, socket,),
2099            0x10a6267f2ab7e24c,
2100            fidl::encoding::DynamicFlags::empty(),
2101            ___deadline,
2102        )?;
2103        Ok(_response)
2104    }
2105}
2106
2107#[cfg(target_os = "fuchsia")]
2108impl From<VirtioConsoleSynchronousProxy> for zx::NullableHandle {
2109    fn from(value: VirtioConsoleSynchronousProxy) -> Self {
2110        value.into_channel().into()
2111    }
2112}
2113
2114#[cfg(target_os = "fuchsia")]
2115impl From<fidl::Channel> for VirtioConsoleSynchronousProxy {
2116    fn from(value: fidl::Channel) -> Self {
2117        Self::new(value)
2118    }
2119}
2120
2121#[cfg(target_os = "fuchsia")]
2122impl fidl::endpoints::FromClient for VirtioConsoleSynchronousProxy {
2123    type Protocol = VirtioConsoleMarker;
2124
2125    fn from_client(value: fidl::endpoints::ClientEnd<VirtioConsoleMarker>) -> Self {
2126        Self::new(value.into_channel())
2127    }
2128}
2129
2130#[derive(Debug, Clone)]
2131pub struct VirtioConsoleProxy {
2132    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2133}
2134
2135impl fidl::endpoints::Proxy for VirtioConsoleProxy {
2136    type Protocol = VirtioConsoleMarker;
2137
2138    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2139        Self::new(inner)
2140    }
2141
2142    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2143        self.client.into_channel().map_err(|client| Self { client })
2144    }
2145
2146    fn as_channel(&self) -> &::fidl::AsyncChannel {
2147        self.client.as_channel()
2148    }
2149}
2150
2151impl VirtioConsoleProxy {
2152    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioConsole.
2153    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2154        let protocol_name = <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2155        Self { client: fidl::client::Client::new(channel, protocol_name) }
2156    }
2157
2158    /// Get a Stream of events from the remote end of the protocol.
2159    ///
2160    /// # Panics
2161    ///
2162    /// Panics if the event stream was already taken.
2163    pub fn take_event_stream(&self) -> VirtioConsoleEventStream {
2164        VirtioConsoleEventStream { event_receiver: self.client.take_event_receiver() }
2165    }
2166
2167    /// Configure a `queue` for the device. This specifies the `size` and the
2168    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2169    pub fn r#configure_queue(
2170        &self,
2171        mut queue: u16,
2172        mut size: u16,
2173        mut desc: u64,
2174        mut avail: u64,
2175        mut used: u64,
2176    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2177        VirtioConsoleProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
2178    }
2179
2180    /// Notify a `queue` for the device. Primarily used for black-box testing.
2181    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2182        VirtioConsoleProxyInterface::r#notify_queue(self, queue)
2183    }
2184
2185    /// Ready a device. This provides the set of `negotiated_features` that the
2186    /// driver and device have agreed upon.
2187    pub fn r#ready(
2188        &self,
2189        mut negotiated_features: u32,
2190    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2191        VirtioConsoleProxyInterface::r#ready(self, negotiated_features)
2192    }
2193
2194    /// Start the console device. This uses `socket` to handle input and output.
2195    pub fn r#start(
2196        &self,
2197        mut start_info: StartInfo,
2198        mut socket: fidl::Socket,
2199    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2200        VirtioConsoleProxyInterface::r#start(self, start_info, socket)
2201    }
2202}
2203
2204impl VirtioConsoleProxyInterface for VirtioConsoleProxy {
2205    type ConfigureQueueResponseFut =
2206        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2207    fn r#configure_queue(
2208        &self,
2209        mut queue: u16,
2210        mut size: u16,
2211        mut desc: u64,
2212        mut avail: u64,
2213        mut used: u64,
2214    ) -> Self::ConfigureQueueResponseFut {
2215        fn _decode(
2216            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2217        ) -> Result<(), fidl::Error> {
2218            let _response = fidl::client::decode_transaction_body::<
2219                fidl::encoding::EmptyPayload,
2220                fidl::encoding::DefaultFuchsiaResourceDialect,
2221                0x72b44fb963480b11,
2222            >(_buf?)?;
2223            Ok(_response)
2224        }
2225        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
2226            (queue, size, desc, avail, used),
2227            0x72b44fb963480b11,
2228            fidl::encoding::DynamicFlags::empty(),
2229            _decode,
2230        )
2231    }
2232
2233    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2234        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2235            (queue,),
2236            0x6e3a61d652499244,
2237            fidl::encoding::DynamicFlags::empty(),
2238        )
2239    }
2240
2241    type ReadyResponseFut =
2242        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2243    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
2244        fn _decode(
2245            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2246        ) -> Result<(), fidl::Error> {
2247            let _response = fidl::client::decode_transaction_body::<
2248                fidl::encoding::EmptyPayload,
2249                fidl::encoding::DefaultFuchsiaResourceDialect,
2250                0x45707654f5d23c3f,
2251            >(_buf?)?;
2252            Ok(_response)
2253        }
2254        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
2255            (negotiated_features,),
2256            0x45707654f5d23c3f,
2257            fidl::encoding::DynamicFlags::empty(),
2258            _decode,
2259        )
2260    }
2261
2262    type StartResponseFut =
2263        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2264    fn r#start(
2265        &self,
2266        mut start_info: StartInfo,
2267        mut socket: fidl::Socket,
2268    ) -> Self::StartResponseFut {
2269        fn _decode(
2270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2271        ) -> Result<(), fidl::Error> {
2272            let _response = fidl::client::decode_transaction_body::<
2273                fidl::encoding::EmptyPayload,
2274                fidl::encoding::DefaultFuchsiaResourceDialect,
2275                0x10a6267f2ab7e24c,
2276            >(_buf?)?;
2277            Ok(_response)
2278        }
2279        self.client.send_query_and_decode::<VirtioConsoleStartRequest, ()>(
2280            (&mut start_info, socket),
2281            0x10a6267f2ab7e24c,
2282            fidl::encoding::DynamicFlags::empty(),
2283            _decode,
2284        )
2285    }
2286}
2287
2288pub struct VirtioConsoleEventStream {
2289    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2290}
2291
2292impl std::marker::Unpin for VirtioConsoleEventStream {}
2293
2294impl futures::stream::FusedStream for VirtioConsoleEventStream {
2295    fn is_terminated(&self) -> bool {
2296        self.event_receiver.is_terminated()
2297    }
2298}
2299
2300impl futures::Stream for VirtioConsoleEventStream {
2301    type Item = Result<VirtioConsoleEvent, fidl::Error>;
2302
2303    fn poll_next(
2304        mut self: std::pin::Pin<&mut Self>,
2305        cx: &mut std::task::Context<'_>,
2306    ) -> std::task::Poll<Option<Self::Item>> {
2307        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2308            &mut self.event_receiver,
2309            cx
2310        )?) {
2311            Some(buf) => std::task::Poll::Ready(Some(VirtioConsoleEvent::decode(buf))),
2312            None => std::task::Poll::Ready(None),
2313        }
2314    }
2315}
2316
2317#[derive(Debug)]
2318pub enum VirtioConsoleEvent {}
2319
2320impl VirtioConsoleEvent {
2321    /// Decodes a message buffer as a [`VirtioConsoleEvent`].
2322    fn decode(
2323        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2324    ) -> Result<VirtioConsoleEvent, fidl::Error> {
2325        let (bytes, _handles) = buf.split_mut();
2326        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2327        debug_assert_eq!(tx_header.tx_id, 0);
2328        match tx_header.ordinal {
2329            _ => Err(fidl::Error::UnknownOrdinal {
2330                ordinal: tx_header.ordinal,
2331                protocol_name: <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2332            }),
2333        }
2334    }
2335}
2336
2337/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioConsole.
2338pub struct VirtioConsoleRequestStream {
2339    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2340    is_terminated: bool,
2341}
2342
2343impl std::marker::Unpin for VirtioConsoleRequestStream {}
2344
2345impl futures::stream::FusedStream for VirtioConsoleRequestStream {
2346    fn is_terminated(&self) -> bool {
2347        self.is_terminated
2348    }
2349}
2350
2351impl fidl::endpoints::RequestStream for VirtioConsoleRequestStream {
2352    type Protocol = VirtioConsoleMarker;
2353    type ControlHandle = VirtioConsoleControlHandle;
2354
2355    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2356        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2357    }
2358
2359    fn control_handle(&self) -> Self::ControlHandle {
2360        VirtioConsoleControlHandle { inner: self.inner.clone() }
2361    }
2362
2363    fn into_inner(
2364        self,
2365    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2366    {
2367        (self.inner, self.is_terminated)
2368    }
2369
2370    fn from_inner(
2371        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2372        is_terminated: bool,
2373    ) -> Self {
2374        Self { inner, is_terminated }
2375    }
2376}
2377
2378impl futures::Stream for VirtioConsoleRequestStream {
2379    type Item = Result<VirtioConsoleRequest, fidl::Error>;
2380
2381    fn poll_next(
2382        mut self: std::pin::Pin<&mut Self>,
2383        cx: &mut std::task::Context<'_>,
2384    ) -> std::task::Poll<Option<Self::Item>> {
2385        let this = &mut *self;
2386        if this.inner.check_shutdown(cx) {
2387            this.is_terminated = true;
2388            return std::task::Poll::Ready(None);
2389        }
2390        if this.is_terminated {
2391            panic!("polled VirtioConsoleRequestStream after completion");
2392        }
2393        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2394            |bytes, handles| {
2395                match this.inner.channel().read_etc(cx, bytes, handles) {
2396                    std::task::Poll::Ready(Ok(())) => {}
2397                    std::task::Poll::Pending => return std::task::Poll::Pending,
2398                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2399                        this.is_terminated = true;
2400                        return std::task::Poll::Ready(None);
2401                    }
2402                    std::task::Poll::Ready(Err(e)) => {
2403                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2404                            e.into(),
2405                        ))));
2406                    }
2407                }
2408
2409                // A message has been received from the channel
2410                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2411
2412                std::task::Poll::Ready(Some(match header.ordinal {
2413                    0x72b44fb963480b11 => {
2414                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2415                        let mut req = fidl::new_empty!(
2416                            VirtioDeviceConfigureQueueRequest,
2417                            fidl::encoding::DefaultFuchsiaResourceDialect
2418                        );
2419                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
2420                        let control_handle =
2421                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2422                        Ok(VirtioConsoleRequest::ConfigureQueue {
2423                            queue: req.queue,
2424                            size: req.size,
2425                            desc: req.desc,
2426                            avail: req.avail,
2427                            used: req.used,
2428
2429                            responder: VirtioConsoleConfigureQueueResponder {
2430                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2431                                tx_id: header.tx_id,
2432                            },
2433                        })
2434                    }
2435                    0x6e3a61d652499244 => {
2436                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2437                        let mut req = fidl::new_empty!(
2438                            VirtioDeviceNotifyQueueRequest,
2439                            fidl::encoding::DefaultFuchsiaResourceDialect
2440                        );
2441                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
2442                        let control_handle =
2443                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2444                        Ok(VirtioConsoleRequest::NotifyQueue { queue: req.queue, control_handle })
2445                    }
2446                    0x45707654f5d23c3f => {
2447                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2448                        let mut req = fidl::new_empty!(
2449                            VirtioDeviceReadyRequest,
2450                            fidl::encoding::DefaultFuchsiaResourceDialect
2451                        );
2452                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
2453                        let control_handle =
2454                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2455                        Ok(VirtioConsoleRequest::Ready {
2456                            negotiated_features: req.negotiated_features,
2457
2458                            responder: VirtioConsoleReadyResponder {
2459                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2460                                tx_id: header.tx_id,
2461                            },
2462                        })
2463                    }
2464                    0x10a6267f2ab7e24c => {
2465                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2466                        let mut req = fidl::new_empty!(
2467                            VirtioConsoleStartRequest,
2468                            fidl::encoding::DefaultFuchsiaResourceDialect
2469                        );
2470                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioConsoleStartRequest>(&header, _body_bytes, handles, &mut req)?;
2471                        let control_handle =
2472                            VirtioConsoleControlHandle { inner: this.inner.clone() };
2473                        Ok(VirtioConsoleRequest::Start {
2474                            start_info: req.start_info,
2475                            socket: req.socket,
2476
2477                            responder: VirtioConsoleStartResponder {
2478                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2479                                tx_id: header.tx_id,
2480                            },
2481                        })
2482                    }
2483                    _ => Err(fidl::Error::UnknownOrdinal {
2484                        ordinal: header.ordinal,
2485                        protocol_name:
2486                            <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2487                    }),
2488                }))
2489            },
2490        )
2491    }
2492}
2493
2494#[derive(Debug)]
2495pub enum VirtioConsoleRequest {
2496    /// Configure a `queue` for the device. This specifies the `size` and the
2497    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2498    ConfigureQueue {
2499        queue: u16,
2500        size: u16,
2501        desc: u64,
2502        avail: u64,
2503        used: u64,
2504        responder: VirtioConsoleConfigureQueueResponder,
2505    },
2506    /// Notify a `queue` for the device. Primarily used for black-box testing.
2507    NotifyQueue { queue: u16, control_handle: VirtioConsoleControlHandle },
2508    /// Ready a device. This provides the set of `negotiated_features` that the
2509    /// driver and device have agreed upon.
2510    Ready { negotiated_features: u32, responder: VirtioConsoleReadyResponder },
2511    /// Start the console device. This uses `socket` to handle input and output.
2512    Start { start_info: StartInfo, socket: fidl::Socket, responder: VirtioConsoleStartResponder },
2513}
2514
2515impl VirtioConsoleRequest {
2516    #[allow(irrefutable_let_patterns)]
2517    pub fn into_configure_queue(
2518        self,
2519    ) -> Option<(u16, u16, u64, u64, u64, VirtioConsoleConfigureQueueResponder)> {
2520        if let VirtioConsoleRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
2521            self
2522        {
2523            Some((queue, size, desc, avail, used, responder))
2524        } else {
2525            None
2526        }
2527    }
2528
2529    #[allow(irrefutable_let_patterns)]
2530    pub fn into_notify_queue(self) -> Option<(u16, VirtioConsoleControlHandle)> {
2531        if let VirtioConsoleRequest::NotifyQueue { queue, control_handle } = self {
2532            Some((queue, control_handle))
2533        } else {
2534            None
2535        }
2536    }
2537
2538    #[allow(irrefutable_let_patterns)]
2539    pub fn into_ready(self) -> Option<(u32, VirtioConsoleReadyResponder)> {
2540        if let VirtioConsoleRequest::Ready { negotiated_features, responder } = self {
2541            Some((negotiated_features, responder))
2542        } else {
2543            None
2544        }
2545    }
2546
2547    #[allow(irrefutable_let_patterns)]
2548    pub fn into_start(self) -> Option<(StartInfo, fidl::Socket, VirtioConsoleStartResponder)> {
2549        if let VirtioConsoleRequest::Start { start_info, socket, responder } = self {
2550            Some((start_info, socket, responder))
2551        } else {
2552            None
2553        }
2554    }
2555
2556    /// Name of the method defined in FIDL
2557    pub fn method_name(&self) -> &'static str {
2558        match *self {
2559            VirtioConsoleRequest::ConfigureQueue { .. } => "configure_queue",
2560            VirtioConsoleRequest::NotifyQueue { .. } => "notify_queue",
2561            VirtioConsoleRequest::Ready { .. } => "ready",
2562            VirtioConsoleRequest::Start { .. } => "start",
2563        }
2564    }
2565}
2566
2567#[derive(Debug, Clone)]
2568pub struct VirtioConsoleControlHandle {
2569    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2570}
2571
2572impl fidl::endpoints::ControlHandle for VirtioConsoleControlHandle {
2573    fn shutdown(&self) {
2574        self.inner.shutdown()
2575    }
2576
2577    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2578        self.inner.shutdown_with_epitaph(status)
2579    }
2580
2581    fn is_closed(&self) -> bool {
2582        self.inner.channel().is_closed()
2583    }
2584    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2585        self.inner.channel().on_closed()
2586    }
2587
2588    #[cfg(target_os = "fuchsia")]
2589    fn signal_peer(
2590        &self,
2591        clear_mask: zx::Signals,
2592        set_mask: zx::Signals,
2593    ) -> Result<(), zx_status::Status> {
2594        use fidl::Peered;
2595        self.inner.channel().signal_peer(clear_mask, set_mask)
2596    }
2597}
2598
2599impl VirtioConsoleControlHandle {}
2600
2601#[must_use = "FIDL methods require a response to be sent"]
2602#[derive(Debug)]
2603pub struct VirtioConsoleConfigureQueueResponder {
2604    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2605    tx_id: u32,
2606}
2607
2608/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2609/// if the responder is dropped without sending a response, so that the client
2610/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2611impl std::ops::Drop for VirtioConsoleConfigureQueueResponder {
2612    fn drop(&mut self) {
2613        self.control_handle.shutdown();
2614        // Safety: drops once, never accessed again
2615        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2616    }
2617}
2618
2619impl fidl::endpoints::Responder for VirtioConsoleConfigureQueueResponder {
2620    type ControlHandle = VirtioConsoleControlHandle;
2621
2622    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2623        &self.control_handle
2624    }
2625
2626    fn drop_without_shutdown(mut self) {
2627        // Safety: drops once, never accessed again due to mem::forget
2628        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2629        // Prevent Drop from running (which would shut down the channel)
2630        std::mem::forget(self);
2631    }
2632}
2633
2634impl VirtioConsoleConfigureQueueResponder {
2635    /// Sends a response to the FIDL transaction.
2636    ///
2637    /// Sets the channel to shutdown if an error occurs.
2638    pub fn send(self) -> Result<(), fidl::Error> {
2639        let _result = self.send_raw();
2640        if _result.is_err() {
2641            self.control_handle.shutdown();
2642        }
2643        self.drop_without_shutdown();
2644        _result
2645    }
2646
2647    /// Similar to "send" but does not shutdown the channel if an error occurs.
2648    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2649        let _result = self.send_raw();
2650        self.drop_without_shutdown();
2651        _result
2652    }
2653
2654    fn send_raw(&self) -> Result<(), fidl::Error> {
2655        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2656            (),
2657            self.tx_id,
2658            0x72b44fb963480b11,
2659            fidl::encoding::DynamicFlags::empty(),
2660        )
2661    }
2662}
2663
2664#[must_use = "FIDL methods require a response to be sent"]
2665#[derive(Debug)]
2666pub struct VirtioConsoleReadyResponder {
2667    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2668    tx_id: u32,
2669}
2670
2671/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2672/// if the responder is dropped without sending a response, so that the client
2673/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2674impl std::ops::Drop for VirtioConsoleReadyResponder {
2675    fn drop(&mut self) {
2676        self.control_handle.shutdown();
2677        // Safety: drops once, never accessed again
2678        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2679    }
2680}
2681
2682impl fidl::endpoints::Responder for VirtioConsoleReadyResponder {
2683    type ControlHandle = VirtioConsoleControlHandle;
2684
2685    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2686        &self.control_handle
2687    }
2688
2689    fn drop_without_shutdown(mut self) {
2690        // Safety: drops once, never accessed again due to mem::forget
2691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2692        // Prevent Drop from running (which would shut down the channel)
2693        std::mem::forget(self);
2694    }
2695}
2696
2697impl VirtioConsoleReadyResponder {
2698    /// Sends a response to the FIDL transaction.
2699    ///
2700    /// Sets the channel to shutdown if an error occurs.
2701    pub fn send(self) -> Result<(), fidl::Error> {
2702        let _result = self.send_raw();
2703        if _result.is_err() {
2704            self.control_handle.shutdown();
2705        }
2706        self.drop_without_shutdown();
2707        _result
2708    }
2709
2710    /// Similar to "send" but does not shutdown the channel if an error occurs.
2711    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2712        let _result = self.send_raw();
2713        self.drop_without_shutdown();
2714        _result
2715    }
2716
2717    fn send_raw(&self) -> Result<(), fidl::Error> {
2718        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2719            (),
2720            self.tx_id,
2721            0x45707654f5d23c3f,
2722            fidl::encoding::DynamicFlags::empty(),
2723        )
2724    }
2725}
2726
2727#[must_use = "FIDL methods require a response to be sent"]
2728#[derive(Debug)]
2729pub struct VirtioConsoleStartResponder {
2730    control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
2731    tx_id: u32,
2732}
2733
2734/// Set the the channel to be shutdown (see [`VirtioConsoleControlHandle::shutdown`])
2735/// if the responder is dropped without sending a response, so that the client
2736/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2737impl std::ops::Drop for VirtioConsoleStartResponder {
2738    fn drop(&mut self) {
2739        self.control_handle.shutdown();
2740        // Safety: drops once, never accessed again
2741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2742    }
2743}
2744
2745impl fidl::endpoints::Responder for VirtioConsoleStartResponder {
2746    type ControlHandle = VirtioConsoleControlHandle;
2747
2748    fn control_handle(&self) -> &VirtioConsoleControlHandle {
2749        &self.control_handle
2750    }
2751
2752    fn drop_without_shutdown(mut self) {
2753        // Safety: drops once, never accessed again due to mem::forget
2754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2755        // Prevent Drop from running (which would shut down the channel)
2756        std::mem::forget(self);
2757    }
2758}
2759
2760impl VirtioConsoleStartResponder {
2761    /// Sends a response to the FIDL transaction.
2762    ///
2763    /// Sets the channel to shutdown if an error occurs.
2764    pub fn send(self) -> Result<(), fidl::Error> {
2765        let _result = self.send_raw();
2766        if _result.is_err() {
2767            self.control_handle.shutdown();
2768        }
2769        self.drop_without_shutdown();
2770        _result
2771    }
2772
2773    /// Similar to "send" but does not shutdown the channel if an error occurs.
2774    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2775        let _result = self.send_raw();
2776        self.drop_without_shutdown();
2777        _result
2778    }
2779
2780    fn send_raw(&self) -> Result<(), fidl::Error> {
2781        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2782            (),
2783            self.tx_id,
2784            0x10a6267f2ab7e24c,
2785            fidl::encoding::DynamicFlags::empty(),
2786        )
2787    }
2788}
2789
2790#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2791pub struct VirtioDeviceMarker;
2792
2793impl fidl::endpoints::ProtocolMarker for VirtioDeviceMarker {
2794    type Proxy = VirtioDeviceProxy;
2795    type RequestStream = VirtioDeviceRequestStream;
2796    #[cfg(target_os = "fuchsia")]
2797    type SynchronousProxy = VirtioDeviceSynchronousProxy;
2798
2799    const DEBUG_NAME: &'static str = "(anonymous) VirtioDevice";
2800}
2801
2802pub trait VirtioDeviceProxyInterface: Send + Sync {
2803    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2804    fn r#configure_queue(
2805        &self,
2806        queue: u16,
2807        size: u16,
2808        desc: u64,
2809        avail: u64,
2810        used: u64,
2811    ) -> Self::ConfigureQueueResponseFut;
2812    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
2813    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2814    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
2815}
2816#[derive(Debug)]
2817#[cfg(target_os = "fuchsia")]
2818pub struct VirtioDeviceSynchronousProxy {
2819    client: fidl::client::sync::Client,
2820}
2821
2822#[cfg(target_os = "fuchsia")]
2823impl fidl::endpoints::SynchronousProxy for VirtioDeviceSynchronousProxy {
2824    type Proxy = VirtioDeviceProxy;
2825    type Protocol = VirtioDeviceMarker;
2826
2827    fn from_channel(inner: fidl::Channel) -> Self {
2828        Self::new(inner)
2829    }
2830
2831    fn into_channel(self) -> fidl::Channel {
2832        self.client.into_channel()
2833    }
2834
2835    fn as_channel(&self) -> &fidl::Channel {
2836        self.client.as_channel()
2837    }
2838}
2839
2840#[cfg(target_os = "fuchsia")]
2841impl VirtioDeviceSynchronousProxy {
2842    pub fn new(channel: fidl::Channel) -> Self {
2843        Self { client: fidl::client::sync::Client::new(channel) }
2844    }
2845
2846    pub fn into_channel(self) -> fidl::Channel {
2847        self.client.into_channel()
2848    }
2849
2850    /// Waits until an event arrives and returns it. It is safe for other
2851    /// threads to make concurrent requests while waiting for an event.
2852    pub fn wait_for_event(
2853        &self,
2854        deadline: zx::MonotonicInstant,
2855    ) -> Result<VirtioDeviceEvent, fidl::Error> {
2856        VirtioDeviceEvent::decode(self.client.wait_for_event::<VirtioDeviceMarker>(deadline)?)
2857    }
2858
2859    /// Configure a `queue` for the device. This specifies the `size` and the
2860    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2861    pub fn r#configure_queue(
2862        &self,
2863        mut queue: u16,
2864        mut size: u16,
2865        mut desc: u64,
2866        mut avail: u64,
2867        mut used: u64,
2868        ___deadline: zx::MonotonicInstant,
2869    ) -> Result<(), fidl::Error> {
2870        let _response = self.client.send_query::<
2871            VirtioDeviceConfigureQueueRequest,
2872            fidl::encoding::EmptyPayload,
2873            VirtioDeviceMarker,
2874        >(
2875            (queue, size, desc, avail, used,),
2876            0x72b44fb963480b11,
2877            fidl::encoding::DynamicFlags::empty(),
2878            ___deadline,
2879        )?;
2880        Ok(_response)
2881    }
2882
2883    /// Notify a `queue` for the device. Primarily used for black-box testing.
2884    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2885        self.client.send::<VirtioDeviceNotifyQueueRequest>(
2886            (queue,),
2887            0x6e3a61d652499244,
2888            fidl::encoding::DynamicFlags::empty(),
2889        )
2890    }
2891
2892    /// Ready a device. This provides the set of `negotiated_features` that the
2893    /// driver and device have agreed upon.
2894    pub fn r#ready(
2895        &self,
2896        mut negotiated_features: u32,
2897        ___deadline: zx::MonotonicInstant,
2898    ) -> Result<(), fidl::Error> {
2899        let _response = self.client.send_query::<
2900            VirtioDeviceReadyRequest,
2901            fidl::encoding::EmptyPayload,
2902            VirtioDeviceMarker,
2903        >(
2904            (negotiated_features,),
2905            0x45707654f5d23c3f,
2906            fidl::encoding::DynamicFlags::empty(),
2907            ___deadline,
2908        )?;
2909        Ok(_response)
2910    }
2911}
2912
2913#[cfg(target_os = "fuchsia")]
2914impl From<VirtioDeviceSynchronousProxy> for zx::NullableHandle {
2915    fn from(value: VirtioDeviceSynchronousProxy) -> Self {
2916        value.into_channel().into()
2917    }
2918}
2919
2920#[cfg(target_os = "fuchsia")]
2921impl From<fidl::Channel> for VirtioDeviceSynchronousProxy {
2922    fn from(value: fidl::Channel) -> Self {
2923        Self::new(value)
2924    }
2925}
2926
2927#[cfg(target_os = "fuchsia")]
2928impl fidl::endpoints::FromClient for VirtioDeviceSynchronousProxy {
2929    type Protocol = VirtioDeviceMarker;
2930
2931    fn from_client(value: fidl::endpoints::ClientEnd<VirtioDeviceMarker>) -> Self {
2932        Self::new(value.into_channel())
2933    }
2934}
2935
2936#[derive(Debug, Clone)]
2937pub struct VirtioDeviceProxy {
2938    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2939}
2940
2941impl fidl::endpoints::Proxy for VirtioDeviceProxy {
2942    type Protocol = VirtioDeviceMarker;
2943
2944    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2945        Self::new(inner)
2946    }
2947
2948    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2949        self.client.into_channel().map_err(|client| Self { client })
2950    }
2951
2952    fn as_channel(&self) -> &::fidl::AsyncChannel {
2953        self.client.as_channel()
2954    }
2955}
2956
2957impl VirtioDeviceProxy {
2958    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioDevice.
2959    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2960        let protocol_name = <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2961        Self { client: fidl::client::Client::new(channel, protocol_name) }
2962    }
2963
2964    /// Get a Stream of events from the remote end of the protocol.
2965    ///
2966    /// # Panics
2967    ///
2968    /// Panics if the event stream was already taken.
2969    pub fn take_event_stream(&self) -> VirtioDeviceEventStream {
2970        VirtioDeviceEventStream { event_receiver: self.client.take_event_receiver() }
2971    }
2972
2973    /// Configure a `queue` for the device. This specifies the `size` and the
2974    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
2975    pub fn r#configure_queue(
2976        &self,
2977        mut queue: u16,
2978        mut size: u16,
2979        mut desc: u64,
2980        mut avail: u64,
2981        mut used: u64,
2982    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2983        VirtioDeviceProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
2984    }
2985
2986    /// Notify a `queue` for the device. Primarily used for black-box testing.
2987    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
2988        VirtioDeviceProxyInterface::r#notify_queue(self, queue)
2989    }
2990
2991    /// Ready a device. This provides the set of `negotiated_features` that the
2992    /// driver and device have agreed upon.
2993    pub fn r#ready(
2994        &self,
2995        mut negotiated_features: u32,
2996    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2997        VirtioDeviceProxyInterface::r#ready(self, negotiated_features)
2998    }
2999}
3000
3001impl VirtioDeviceProxyInterface for VirtioDeviceProxy {
3002    type ConfigureQueueResponseFut =
3003        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3004    fn r#configure_queue(
3005        &self,
3006        mut queue: u16,
3007        mut size: u16,
3008        mut desc: u64,
3009        mut avail: u64,
3010        mut used: u64,
3011    ) -> Self::ConfigureQueueResponseFut {
3012        fn _decode(
3013            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3014        ) -> Result<(), fidl::Error> {
3015            let _response = fidl::client::decode_transaction_body::<
3016                fidl::encoding::EmptyPayload,
3017                fidl::encoding::DefaultFuchsiaResourceDialect,
3018                0x72b44fb963480b11,
3019            >(_buf?)?;
3020            Ok(_response)
3021        }
3022        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
3023            (queue, size, desc, avail, used),
3024            0x72b44fb963480b11,
3025            fidl::encoding::DynamicFlags::empty(),
3026            _decode,
3027        )
3028    }
3029
3030    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3031        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3032            (queue,),
3033            0x6e3a61d652499244,
3034            fidl::encoding::DynamicFlags::empty(),
3035        )
3036    }
3037
3038    type ReadyResponseFut =
3039        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3040    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
3041        fn _decode(
3042            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3043        ) -> Result<(), fidl::Error> {
3044            let _response = fidl::client::decode_transaction_body::<
3045                fidl::encoding::EmptyPayload,
3046                fidl::encoding::DefaultFuchsiaResourceDialect,
3047                0x45707654f5d23c3f,
3048            >(_buf?)?;
3049            Ok(_response)
3050        }
3051        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
3052            (negotiated_features,),
3053            0x45707654f5d23c3f,
3054            fidl::encoding::DynamicFlags::empty(),
3055            _decode,
3056        )
3057    }
3058}
3059
3060pub struct VirtioDeviceEventStream {
3061    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3062}
3063
3064impl std::marker::Unpin for VirtioDeviceEventStream {}
3065
3066impl futures::stream::FusedStream for VirtioDeviceEventStream {
3067    fn is_terminated(&self) -> bool {
3068        self.event_receiver.is_terminated()
3069    }
3070}
3071
3072impl futures::Stream for VirtioDeviceEventStream {
3073    type Item = Result<VirtioDeviceEvent, fidl::Error>;
3074
3075    fn poll_next(
3076        mut self: std::pin::Pin<&mut Self>,
3077        cx: &mut std::task::Context<'_>,
3078    ) -> std::task::Poll<Option<Self::Item>> {
3079        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3080            &mut self.event_receiver,
3081            cx
3082        )?) {
3083            Some(buf) => std::task::Poll::Ready(Some(VirtioDeviceEvent::decode(buf))),
3084            None => std::task::Poll::Ready(None),
3085        }
3086    }
3087}
3088
3089#[derive(Debug)]
3090pub enum VirtioDeviceEvent {}
3091
3092impl VirtioDeviceEvent {
3093    /// Decodes a message buffer as a [`VirtioDeviceEvent`].
3094    fn decode(
3095        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3096    ) -> Result<VirtioDeviceEvent, fidl::Error> {
3097        let (bytes, _handles) = buf.split_mut();
3098        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3099        debug_assert_eq!(tx_header.tx_id, 0);
3100        match tx_header.ordinal {
3101            _ => Err(fidl::Error::UnknownOrdinal {
3102                ordinal: tx_header.ordinal,
3103                protocol_name: <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3104            }),
3105        }
3106    }
3107}
3108
3109/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioDevice.
3110pub struct VirtioDeviceRequestStream {
3111    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3112    is_terminated: bool,
3113}
3114
3115impl std::marker::Unpin for VirtioDeviceRequestStream {}
3116
3117impl futures::stream::FusedStream for VirtioDeviceRequestStream {
3118    fn is_terminated(&self) -> bool {
3119        self.is_terminated
3120    }
3121}
3122
3123impl fidl::endpoints::RequestStream for VirtioDeviceRequestStream {
3124    type Protocol = VirtioDeviceMarker;
3125    type ControlHandle = VirtioDeviceControlHandle;
3126
3127    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3128        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3129    }
3130
3131    fn control_handle(&self) -> Self::ControlHandle {
3132        VirtioDeviceControlHandle { inner: self.inner.clone() }
3133    }
3134
3135    fn into_inner(
3136        self,
3137    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3138    {
3139        (self.inner, self.is_terminated)
3140    }
3141
3142    fn from_inner(
3143        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3144        is_terminated: bool,
3145    ) -> Self {
3146        Self { inner, is_terminated }
3147    }
3148}
3149
3150impl futures::Stream for VirtioDeviceRequestStream {
3151    type Item = Result<VirtioDeviceRequest, fidl::Error>;
3152
3153    fn poll_next(
3154        mut self: std::pin::Pin<&mut Self>,
3155        cx: &mut std::task::Context<'_>,
3156    ) -> std::task::Poll<Option<Self::Item>> {
3157        let this = &mut *self;
3158        if this.inner.check_shutdown(cx) {
3159            this.is_terminated = true;
3160            return std::task::Poll::Ready(None);
3161        }
3162        if this.is_terminated {
3163            panic!("polled VirtioDeviceRequestStream after completion");
3164        }
3165        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3166            |bytes, handles| {
3167                match this.inner.channel().read_etc(cx, bytes, handles) {
3168                    std::task::Poll::Ready(Ok(())) => {}
3169                    std::task::Poll::Pending => return std::task::Poll::Pending,
3170                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3171                        this.is_terminated = true;
3172                        return std::task::Poll::Ready(None);
3173                    }
3174                    std::task::Poll::Ready(Err(e)) => {
3175                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3176                            e.into(),
3177                        ))));
3178                    }
3179                }
3180
3181                // A message has been received from the channel
3182                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3183
3184                std::task::Poll::Ready(Some(match header.ordinal {
3185                    0x72b44fb963480b11 => {
3186                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3187                        let mut req = fidl::new_empty!(
3188                            VirtioDeviceConfigureQueueRequest,
3189                            fidl::encoding::DefaultFuchsiaResourceDialect
3190                        );
3191                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3192                        let control_handle =
3193                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3194                        Ok(VirtioDeviceRequest::ConfigureQueue {
3195                            queue: req.queue,
3196                            size: req.size,
3197                            desc: req.desc,
3198                            avail: req.avail,
3199                            used: req.used,
3200
3201                            responder: VirtioDeviceConfigureQueueResponder {
3202                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3203                                tx_id: header.tx_id,
3204                            },
3205                        })
3206                    }
3207                    0x6e3a61d652499244 => {
3208                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3209                        let mut req = fidl::new_empty!(
3210                            VirtioDeviceNotifyQueueRequest,
3211                            fidl::encoding::DefaultFuchsiaResourceDialect
3212                        );
3213                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3214                        let control_handle =
3215                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3216                        Ok(VirtioDeviceRequest::NotifyQueue { queue: req.queue, control_handle })
3217                    }
3218                    0x45707654f5d23c3f => {
3219                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3220                        let mut req = fidl::new_empty!(
3221                            VirtioDeviceReadyRequest,
3222                            fidl::encoding::DefaultFuchsiaResourceDialect
3223                        );
3224                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
3225                        let control_handle =
3226                            VirtioDeviceControlHandle { inner: this.inner.clone() };
3227                        Ok(VirtioDeviceRequest::Ready {
3228                            negotiated_features: req.negotiated_features,
3229
3230                            responder: VirtioDeviceReadyResponder {
3231                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3232                                tx_id: header.tx_id,
3233                            },
3234                        })
3235                    }
3236                    _ => Err(fidl::Error::UnknownOrdinal {
3237                        ordinal: header.ordinal,
3238                        protocol_name:
3239                            <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3240                    }),
3241                }))
3242            },
3243        )
3244    }
3245}
3246
3247#[derive(Debug)]
3248pub enum VirtioDeviceRequest {
3249    /// Configure a `queue` for the device. This specifies the `size` and the
3250    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3251    ConfigureQueue {
3252        queue: u16,
3253        size: u16,
3254        desc: u64,
3255        avail: u64,
3256        used: u64,
3257        responder: VirtioDeviceConfigureQueueResponder,
3258    },
3259    /// Notify a `queue` for the device. Primarily used for black-box testing.
3260    NotifyQueue { queue: u16, control_handle: VirtioDeviceControlHandle },
3261    /// Ready a device. This provides the set of `negotiated_features` that the
3262    /// driver and device have agreed upon.
3263    Ready { negotiated_features: u32, responder: VirtioDeviceReadyResponder },
3264}
3265
3266impl VirtioDeviceRequest {
3267    #[allow(irrefutable_let_patterns)]
3268    pub fn into_configure_queue(
3269        self,
3270    ) -> Option<(u16, u16, u64, u64, u64, VirtioDeviceConfigureQueueResponder)> {
3271        if let VirtioDeviceRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
3272            self
3273        {
3274            Some((queue, size, desc, avail, used, responder))
3275        } else {
3276            None
3277        }
3278    }
3279
3280    #[allow(irrefutable_let_patterns)]
3281    pub fn into_notify_queue(self) -> Option<(u16, VirtioDeviceControlHandle)> {
3282        if let VirtioDeviceRequest::NotifyQueue { queue, control_handle } = self {
3283            Some((queue, control_handle))
3284        } else {
3285            None
3286        }
3287    }
3288
3289    #[allow(irrefutable_let_patterns)]
3290    pub fn into_ready(self) -> Option<(u32, VirtioDeviceReadyResponder)> {
3291        if let VirtioDeviceRequest::Ready { negotiated_features, responder } = self {
3292            Some((negotiated_features, responder))
3293        } else {
3294            None
3295        }
3296    }
3297
3298    /// Name of the method defined in FIDL
3299    pub fn method_name(&self) -> &'static str {
3300        match *self {
3301            VirtioDeviceRequest::ConfigureQueue { .. } => "configure_queue",
3302            VirtioDeviceRequest::NotifyQueue { .. } => "notify_queue",
3303            VirtioDeviceRequest::Ready { .. } => "ready",
3304        }
3305    }
3306}
3307
3308#[derive(Debug, Clone)]
3309pub struct VirtioDeviceControlHandle {
3310    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3311}
3312
3313impl fidl::endpoints::ControlHandle for VirtioDeviceControlHandle {
3314    fn shutdown(&self) {
3315        self.inner.shutdown()
3316    }
3317
3318    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3319        self.inner.shutdown_with_epitaph(status)
3320    }
3321
3322    fn is_closed(&self) -> bool {
3323        self.inner.channel().is_closed()
3324    }
3325    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3326        self.inner.channel().on_closed()
3327    }
3328
3329    #[cfg(target_os = "fuchsia")]
3330    fn signal_peer(
3331        &self,
3332        clear_mask: zx::Signals,
3333        set_mask: zx::Signals,
3334    ) -> Result<(), zx_status::Status> {
3335        use fidl::Peered;
3336        self.inner.channel().signal_peer(clear_mask, set_mask)
3337    }
3338}
3339
3340impl VirtioDeviceControlHandle {}
3341
3342#[must_use = "FIDL methods require a response to be sent"]
3343#[derive(Debug)]
3344pub struct VirtioDeviceConfigureQueueResponder {
3345    control_handle: std::mem::ManuallyDrop<VirtioDeviceControlHandle>,
3346    tx_id: u32,
3347}
3348
3349/// Set the the channel to be shutdown (see [`VirtioDeviceControlHandle::shutdown`])
3350/// if the responder is dropped without sending a response, so that the client
3351/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3352impl std::ops::Drop for VirtioDeviceConfigureQueueResponder {
3353    fn drop(&mut self) {
3354        self.control_handle.shutdown();
3355        // Safety: drops once, never accessed again
3356        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3357    }
3358}
3359
3360impl fidl::endpoints::Responder for VirtioDeviceConfigureQueueResponder {
3361    type ControlHandle = VirtioDeviceControlHandle;
3362
3363    fn control_handle(&self) -> &VirtioDeviceControlHandle {
3364        &self.control_handle
3365    }
3366
3367    fn drop_without_shutdown(mut self) {
3368        // Safety: drops once, never accessed again due to mem::forget
3369        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3370        // Prevent Drop from running (which would shut down the channel)
3371        std::mem::forget(self);
3372    }
3373}
3374
3375impl VirtioDeviceConfigureQueueResponder {
3376    /// Sends a response to the FIDL transaction.
3377    ///
3378    /// Sets the channel to shutdown if an error occurs.
3379    pub fn send(self) -> Result<(), fidl::Error> {
3380        let _result = self.send_raw();
3381        if _result.is_err() {
3382            self.control_handle.shutdown();
3383        }
3384        self.drop_without_shutdown();
3385        _result
3386    }
3387
3388    /// Similar to "send" but does not shutdown the channel if an error occurs.
3389    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3390        let _result = self.send_raw();
3391        self.drop_without_shutdown();
3392        _result
3393    }
3394
3395    fn send_raw(&self) -> Result<(), fidl::Error> {
3396        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3397            (),
3398            self.tx_id,
3399            0x72b44fb963480b11,
3400            fidl::encoding::DynamicFlags::empty(),
3401        )
3402    }
3403}
3404
3405#[must_use = "FIDL methods require a response to be sent"]
3406#[derive(Debug)]
3407pub struct VirtioDeviceReadyResponder {
3408    control_handle: std::mem::ManuallyDrop<VirtioDeviceControlHandle>,
3409    tx_id: u32,
3410}
3411
3412/// Set the the channel to be shutdown (see [`VirtioDeviceControlHandle::shutdown`])
3413/// if the responder is dropped without sending a response, so that the client
3414/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3415impl std::ops::Drop for VirtioDeviceReadyResponder {
3416    fn drop(&mut self) {
3417        self.control_handle.shutdown();
3418        // Safety: drops once, never accessed again
3419        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3420    }
3421}
3422
3423impl fidl::endpoints::Responder for VirtioDeviceReadyResponder {
3424    type ControlHandle = VirtioDeviceControlHandle;
3425
3426    fn control_handle(&self) -> &VirtioDeviceControlHandle {
3427        &self.control_handle
3428    }
3429
3430    fn drop_without_shutdown(mut self) {
3431        // Safety: drops once, never accessed again due to mem::forget
3432        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3433        // Prevent Drop from running (which would shut down the channel)
3434        std::mem::forget(self);
3435    }
3436}
3437
3438impl VirtioDeviceReadyResponder {
3439    /// Sends a response to the FIDL transaction.
3440    ///
3441    /// Sets the channel to shutdown if an error occurs.
3442    pub fn send(self) -> Result<(), fidl::Error> {
3443        let _result = self.send_raw();
3444        if _result.is_err() {
3445            self.control_handle.shutdown();
3446        }
3447        self.drop_without_shutdown();
3448        _result
3449    }
3450
3451    /// Similar to "send" but does not shutdown the channel if an error occurs.
3452    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3453        let _result = self.send_raw();
3454        self.drop_without_shutdown();
3455        _result
3456    }
3457
3458    fn send_raw(&self) -> Result<(), fidl::Error> {
3459        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3460            (),
3461            self.tx_id,
3462            0x45707654f5d23c3f,
3463            fidl::encoding::DynamicFlags::empty(),
3464        )
3465    }
3466}
3467
3468#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3469pub struct VirtioGpuMarker;
3470
3471impl fidl::endpoints::ProtocolMarker for VirtioGpuMarker {
3472    type Proxy = VirtioGpuProxy;
3473    type RequestStream = VirtioGpuRequestStream;
3474    #[cfg(target_os = "fuchsia")]
3475    type SynchronousProxy = VirtioGpuSynchronousProxy;
3476
3477    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioGpu";
3478}
3479impl fidl::endpoints::DiscoverableProtocolMarker for VirtioGpuMarker {}
3480
3481pub trait VirtioGpuProxyInterface: Send + Sync {
3482    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3483    fn r#configure_queue(
3484        &self,
3485        queue: u16,
3486        size: u16,
3487        desc: u64,
3488        avail: u64,
3489        used: u64,
3490    ) -> Self::ConfigureQueueResponseFut;
3491    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
3492    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3493    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
3494    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3495    fn r#start(
3496        &self,
3497        start_info: StartInfo,
3498        keyboard_listener: Option<
3499            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3500        >,
3501        mouse_source: Option<
3502            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3503        >,
3504    ) -> Self::StartResponseFut;
3505}
3506#[derive(Debug)]
3507#[cfg(target_os = "fuchsia")]
3508pub struct VirtioGpuSynchronousProxy {
3509    client: fidl::client::sync::Client,
3510}
3511
3512#[cfg(target_os = "fuchsia")]
3513impl fidl::endpoints::SynchronousProxy for VirtioGpuSynchronousProxy {
3514    type Proxy = VirtioGpuProxy;
3515    type Protocol = VirtioGpuMarker;
3516
3517    fn from_channel(inner: fidl::Channel) -> Self {
3518        Self::new(inner)
3519    }
3520
3521    fn into_channel(self) -> fidl::Channel {
3522        self.client.into_channel()
3523    }
3524
3525    fn as_channel(&self) -> &fidl::Channel {
3526        self.client.as_channel()
3527    }
3528}
3529
3530#[cfg(target_os = "fuchsia")]
3531impl VirtioGpuSynchronousProxy {
3532    pub fn new(channel: fidl::Channel) -> Self {
3533        Self { client: fidl::client::sync::Client::new(channel) }
3534    }
3535
3536    pub fn into_channel(self) -> fidl::Channel {
3537        self.client.into_channel()
3538    }
3539
3540    /// Waits until an event arrives and returns it. It is safe for other
3541    /// threads to make concurrent requests while waiting for an event.
3542    pub fn wait_for_event(
3543        &self,
3544        deadline: zx::MonotonicInstant,
3545    ) -> Result<VirtioGpuEvent, fidl::Error> {
3546        VirtioGpuEvent::decode(self.client.wait_for_event::<VirtioGpuMarker>(deadline)?)
3547    }
3548
3549    /// Configure a `queue` for the device. This specifies the `size` and the
3550    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3551    pub fn r#configure_queue(
3552        &self,
3553        mut queue: u16,
3554        mut size: u16,
3555        mut desc: u64,
3556        mut avail: u64,
3557        mut used: u64,
3558        ___deadline: zx::MonotonicInstant,
3559    ) -> Result<(), fidl::Error> {
3560        let _response = self.client.send_query::<
3561            VirtioDeviceConfigureQueueRequest,
3562            fidl::encoding::EmptyPayload,
3563            VirtioGpuMarker,
3564        >(
3565            (queue, size, desc, avail, used,),
3566            0x72b44fb963480b11,
3567            fidl::encoding::DynamicFlags::empty(),
3568            ___deadline,
3569        )?;
3570        Ok(_response)
3571    }
3572
3573    /// Notify a `queue` for the device. Primarily used for black-box testing.
3574    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3575        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3576            (queue,),
3577            0x6e3a61d652499244,
3578            fidl::encoding::DynamicFlags::empty(),
3579        )
3580    }
3581
3582    /// Ready a device. This provides the set of `negotiated_features` that the
3583    /// driver and device have agreed upon.
3584    pub fn r#ready(
3585        &self,
3586        mut negotiated_features: u32,
3587        ___deadline: zx::MonotonicInstant,
3588    ) -> Result<(), fidl::Error> {
3589        let _response = self
3590            .client
3591            .send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload, VirtioGpuMarker>(
3592                (negotiated_features,),
3593                0x45707654f5d23c3f,
3594                fidl::encoding::DynamicFlags::empty(),
3595                ___deadline,
3596            )?;
3597        Ok(_response)
3598    }
3599
3600    /// Start the GPU device.
3601    pub fn r#start(
3602        &self,
3603        mut start_info: StartInfo,
3604        mut keyboard_listener: Option<
3605            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3606        >,
3607        mut mouse_source: Option<
3608            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3609        >,
3610        ___deadline: zx::MonotonicInstant,
3611    ) -> Result<(), fidl::Error> {
3612        let _response = self
3613            .client
3614            .send_query::<VirtioGpuStartRequest, fidl::encoding::EmptyPayload, VirtioGpuMarker>(
3615                (&mut start_info, keyboard_listener, mouse_source),
3616                0x7e81ed410f770c14,
3617                fidl::encoding::DynamicFlags::empty(),
3618                ___deadline,
3619            )?;
3620        Ok(_response)
3621    }
3622}
3623
3624#[cfg(target_os = "fuchsia")]
3625impl From<VirtioGpuSynchronousProxy> for zx::NullableHandle {
3626    fn from(value: VirtioGpuSynchronousProxy) -> Self {
3627        value.into_channel().into()
3628    }
3629}
3630
3631#[cfg(target_os = "fuchsia")]
3632impl From<fidl::Channel> for VirtioGpuSynchronousProxy {
3633    fn from(value: fidl::Channel) -> Self {
3634        Self::new(value)
3635    }
3636}
3637
3638#[cfg(target_os = "fuchsia")]
3639impl fidl::endpoints::FromClient for VirtioGpuSynchronousProxy {
3640    type Protocol = VirtioGpuMarker;
3641
3642    fn from_client(value: fidl::endpoints::ClientEnd<VirtioGpuMarker>) -> Self {
3643        Self::new(value.into_channel())
3644    }
3645}
3646
3647#[derive(Debug, Clone)]
3648pub struct VirtioGpuProxy {
3649    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3650}
3651
3652impl fidl::endpoints::Proxy for VirtioGpuProxy {
3653    type Protocol = VirtioGpuMarker;
3654
3655    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3656        Self::new(inner)
3657    }
3658
3659    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3660        self.client.into_channel().map_err(|client| Self { client })
3661    }
3662
3663    fn as_channel(&self) -> &::fidl::AsyncChannel {
3664        self.client.as_channel()
3665    }
3666}
3667
3668impl VirtioGpuProxy {
3669    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioGpu.
3670    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3671        let protocol_name = <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3672        Self { client: fidl::client::Client::new(channel, protocol_name) }
3673    }
3674
3675    /// Get a Stream of events from the remote end of the protocol.
3676    ///
3677    /// # Panics
3678    ///
3679    /// Panics if the event stream was already taken.
3680    pub fn take_event_stream(&self) -> VirtioGpuEventStream {
3681        VirtioGpuEventStream { event_receiver: self.client.take_event_receiver() }
3682    }
3683
3684    /// Configure a `queue` for the device. This specifies the `size` and the
3685    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
3686    pub fn r#configure_queue(
3687        &self,
3688        mut queue: u16,
3689        mut size: u16,
3690        mut desc: u64,
3691        mut avail: u64,
3692        mut used: u64,
3693    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3694        VirtioGpuProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
3695    }
3696
3697    /// Notify a `queue` for the device. Primarily used for black-box testing.
3698    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3699        VirtioGpuProxyInterface::r#notify_queue(self, queue)
3700    }
3701
3702    /// Ready a device. This provides the set of `negotiated_features` that the
3703    /// driver and device have agreed upon.
3704    pub fn r#ready(
3705        &self,
3706        mut negotiated_features: u32,
3707    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3708        VirtioGpuProxyInterface::r#ready(self, negotiated_features)
3709    }
3710
3711    /// Start the GPU device.
3712    pub fn r#start(
3713        &self,
3714        mut start_info: StartInfo,
3715        mut keyboard_listener: Option<
3716            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3717        >,
3718        mut mouse_source: Option<
3719            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3720        >,
3721    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3722        VirtioGpuProxyInterface::r#start(self, start_info, keyboard_listener, mouse_source)
3723    }
3724}
3725
3726impl VirtioGpuProxyInterface for VirtioGpuProxy {
3727    type ConfigureQueueResponseFut =
3728        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3729    fn r#configure_queue(
3730        &self,
3731        mut queue: u16,
3732        mut size: u16,
3733        mut desc: u64,
3734        mut avail: u64,
3735        mut used: u64,
3736    ) -> Self::ConfigureQueueResponseFut {
3737        fn _decode(
3738            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3739        ) -> Result<(), fidl::Error> {
3740            let _response = fidl::client::decode_transaction_body::<
3741                fidl::encoding::EmptyPayload,
3742                fidl::encoding::DefaultFuchsiaResourceDialect,
3743                0x72b44fb963480b11,
3744            >(_buf?)?;
3745            Ok(_response)
3746        }
3747        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
3748            (queue, size, desc, avail, used),
3749            0x72b44fb963480b11,
3750            fidl::encoding::DynamicFlags::empty(),
3751            _decode,
3752        )
3753    }
3754
3755    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
3756        self.client.send::<VirtioDeviceNotifyQueueRequest>(
3757            (queue,),
3758            0x6e3a61d652499244,
3759            fidl::encoding::DynamicFlags::empty(),
3760        )
3761    }
3762
3763    type ReadyResponseFut =
3764        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3765    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
3766        fn _decode(
3767            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3768        ) -> Result<(), fidl::Error> {
3769            let _response = fidl::client::decode_transaction_body::<
3770                fidl::encoding::EmptyPayload,
3771                fidl::encoding::DefaultFuchsiaResourceDialect,
3772                0x45707654f5d23c3f,
3773            >(_buf?)?;
3774            Ok(_response)
3775        }
3776        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
3777            (negotiated_features,),
3778            0x45707654f5d23c3f,
3779            fidl::encoding::DynamicFlags::empty(),
3780            _decode,
3781        )
3782    }
3783
3784    type StartResponseFut =
3785        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3786    fn r#start(
3787        &self,
3788        mut start_info: StartInfo,
3789        mut keyboard_listener: Option<
3790            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
3791        >,
3792        mut mouse_source: Option<
3793            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
3794        >,
3795    ) -> Self::StartResponseFut {
3796        fn _decode(
3797            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3798        ) -> Result<(), fidl::Error> {
3799            let _response = fidl::client::decode_transaction_body::<
3800                fidl::encoding::EmptyPayload,
3801                fidl::encoding::DefaultFuchsiaResourceDialect,
3802                0x7e81ed410f770c14,
3803            >(_buf?)?;
3804            Ok(_response)
3805        }
3806        self.client.send_query_and_decode::<VirtioGpuStartRequest, ()>(
3807            (&mut start_info, keyboard_listener, mouse_source),
3808            0x7e81ed410f770c14,
3809            fidl::encoding::DynamicFlags::empty(),
3810            _decode,
3811        )
3812    }
3813}
3814
3815pub struct VirtioGpuEventStream {
3816    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3817}
3818
3819impl std::marker::Unpin for VirtioGpuEventStream {}
3820
3821impl futures::stream::FusedStream for VirtioGpuEventStream {
3822    fn is_terminated(&self) -> bool {
3823        self.event_receiver.is_terminated()
3824    }
3825}
3826
3827impl futures::Stream for VirtioGpuEventStream {
3828    type Item = Result<VirtioGpuEvent, fidl::Error>;
3829
3830    fn poll_next(
3831        mut self: std::pin::Pin<&mut Self>,
3832        cx: &mut std::task::Context<'_>,
3833    ) -> std::task::Poll<Option<Self::Item>> {
3834        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3835            &mut self.event_receiver,
3836            cx
3837        )?) {
3838            Some(buf) => std::task::Poll::Ready(Some(VirtioGpuEvent::decode(buf))),
3839            None => std::task::Poll::Ready(None),
3840        }
3841    }
3842}
3843
3844#[derive(Debug)]
3845pub enum VirtioGpuEvent {
3846    OnConfigChanged {},
3847}
3848
3849impl VirtioGpuEvent {
3850    #[allow(irrefutable_let_patterns)]
3851    pub fn into_on_config_changed(self) -> Option<()> {
3852        if let VirtioGpuEvent::OnConfigChanged {} = self { Some(()) } else { None }
3853    }
3854
3855    /// Decodes a message buffer as a [`VirtioGpuEvent`].
3856    fn decode(
3857        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3858    ) -> Result<VirtioGpuEvent, fidl::Error> {
3859        let (bytes, _handles) = buf.split_mut();
3860        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3861        debug_assert_eq!(tx_header.tx_id, 0);
3862        match tx_header.ordinal {
3863            0x1555f5b7c8444aa0 => {
3864                let mut out = fidl::new_empty!(
3865                    fidl::encoding::EmptyPayload,
3866                    fidl::encoding::DefaultFuchsiaResourceDialect
3867                );
3868                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3869                Ok((VirtioGpuEvent::OnConfigChanged {}))
3870            }
3871            _ => Err(fidl::Error::UnknownOrdinal {
3872                ordinal: tx_header.ordinal,
3873                protocol_name: <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3874            }),
3875        }
3876    }
3877}
3878
3879/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioGpu.
3880pub struct VirtioGpuRequestStream {
3881    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3882    is_terminated: bool,
3883}
3884
3885impl std::marker::Unpin for VirtioGpuRequestStream {}
3886
3887impl futures::stream::FusedStream for VirtioGpuRequestStream {
3888    fn is_terminated(&self) -> bool {
3889        self.is_terminated
3890    }
3891}
3892
3893impl fidl::endpoints::RequestStream for VirtioGpuRequestStream {
3894    type Protocol = VirtioGpuMarker;
3895    type ControlHandle = VirtioGpuControlHandle;
3896
3897    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3898        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3899    }
3900
3901    fn control_handle(&self) -> Self::ControlHandle {
3902        VirtioGpuControlHandle { inner: self.inner.clone() }
3903    }
3904
3905    fn into_inner(
3906        self,
3907    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3908    {
3909        (self.inner, self.is_terminated)
3910    }
3911
3912    fn from_inner(
3913        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3914        is_terminated: bool,
3915    ) -> Self {
3916        Self { inner, is_terminated }
3917    }
3918}
3919
3920impl futures::Stream for VirtioGpuRequestStream {
3921    type Item = Result<VirtioGpuRequest, fidl::Error>;
3922
3923    fn poll_next(
3924        mut self: std::pin::Pin<&mut Self>,
3925        cx: &mut std::task::Context<'_>,
3926    ) -> std::task::Poll<Option<Self::Item>> {
3927        let this = &mut *self;
3928        if this.inner.check_shutdown(cx) {
3929            this.is_terminated = true;
3930            return std::task::Poll::Ready(None);
3931        }
3932        if this.is_terminated {
3933            panic!("polled VirtioGpuRequestStream after completion");
3934        }
3935        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3936            |bytes, handles| {
3937                match this.inner.channel().read_etc(cx, bytes, handles) {
3938                    std::task::Poll::Ready(Ok(())) => {}
3939                    std::task::Poll::Pending => return std::task::Poll::Pending,
3940                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3941                        this.is_terminated = true;
3942                        return std::task::Poll::Ready(None);
3943                    }
3944                    std::task::Poll::Ready(Err(e)) => {
3945                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3946                            e.into(),
3947                        ))));
3948                    }
3949                }
3950
3951                // A message has been received from the channel
3952                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3953
3954                std::task::Poll::Ready(Some(match header.ordinal {
3955                    0x72b44fb963480b11 => {
3956                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3957                        let mut req = fidl::new_empty!(
3958                            VirtioDeviceConfigureQueueRequest,
3959                            fidl::encoding::DefaultFuchsiaResourceDialect
3960                        );
3961                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3962                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
3963                        Ok(VirtioGpuRequest::ConfigureQueue {
3964                            queue: req.queue,
3965                            size: req.size,
3966                            desc: req.desc,
3967                            avail: req.avail,
3968                            used: req.used,
3969
3970                            responder: VirtioGpuConfigureQueueResponder {
3971                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3972                                tx_id: header.tx_id,
3973                            },
3974                        })
3975                    }
3976                    0x6e3a61d652499244 => {
3977                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3978                        let mut req = fidl::new_empty!(
3979                            VirtioDeviceNotifyQueueRequest,
3980                            fidl::encoding::DefaultFuchsiaResourceDialect
3981                        );
3982                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
3983                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
3984                        Ok(VirtioGpuRequest::NotifyQueue { queue: req.queue, control_handle })
3985                    }
3986                    0x45707654f5d23c3f => {
3987                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3988                        let mut req = fidl::new_empty!(
3989                            VirtioDeviceReadyRequest,
3990                            fidl::encoding::DefaultFuchsiaResourceDialect
3991                        );
3992                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
3993                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
3994                        Ok(VirtioGpuRequest::Ready {
3995                            negotiated_features: req.negotiated_features,
3996
3997                            responder: VirtioGpuReadyResponder {
3998                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3999                                tx_id: header.tx_id,
4000                            },
4001                        })
4002                    }
4003                    0x7e81ed410f770c14 => {
4004                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4005                        let mut req = fidl::new_empty!(
4006                            VirtioGpuStartRequest,
4007                            fidl::encoding::DefaultFuchsiaResourceDialect
4008                        );
4009                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioGpuStartRequest>(&header, _body_bytes, handles, &mut req)?;
4010                        let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
4011                        Ok(VirtioGpuRequest::Start {
4012                            start_info: req.start_info,
4013                            keyboard_listener: req.keyboard_listener,
4014                            mouse_source: req.mouse_source,
4015
4016                            responder: VirtioGpuStartResponder {
4017                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4018                                tx_id: header.tx_id,
4019                            },
4020                        })
4021                    }
4022                    _ => Err(fidl::Error::UnknownOrdinal {
4023                        ordinal: header.ordinal,
4024                        protocol_name:
4025                            <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4026                    }),
4027                }))
4028            },
4029        )
4030    }
4031}
4032
4033#[derive(Debug)]
4034pub enum VirtioGpuRequest {
4035    /// Configure a `queue` for the device. This specifies the `size` and the
4036    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4037    ConfigureQueue {
4038        queue: u16,
4039        size: u16,
4040        desc: u64,
4041        avail: u64,
4042        used: u64,
4043        responder: VirtioGpuConfigureQueueResponder,
4044    },
4045    /// Notify a `queue` for the device. Primarily used for black-box testing.
4046    NotifyQueue { queue: u16, control_handle: VirtioGpuControlHandle },
4047    /// Ready a device. This provides the set of `negotiated_features` that the
4048    /// driver and device have agreed upon.
4049    Ready { negotiated_features: u32, responder: VirtioGpuReadyResponder },
4050    /// Start the GPU device.
4051    Start {
4052        start_info: StartInfo,
4053        keyboard_listener:
4054            Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
4055        mouse_source:
4056            Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
4057        responder: VirtioGpuStartResponder,
4058    },
4059}
4060
4061impl VirtioGpuRequest {
4062    #[allow(irrefutable_let_patterns)]
4063    pub fn into_configure_queue(
4064        self,
4065    ) -> Option<(u16, u16, u64, u64, u64, VirtioGpuConfigureQueueResponder)> {
4066        if let VirtioGpuRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
4067        {
4068            Some((queue, size, desc, avail, used, responder))
4069        } else {
4070            None
4071        }
4072    }
4073
4074    #[allow(irrefutable_let_patterns)]
4075    pub fn into_notify_queue(self) -> Option<(u16, VirtioGpuControlHandle)> {
4076        if let VirtioGpuRequest::NotifyQueue { queue, control_handle } = self {
4077            Some((queue, control_handle))
4078        } else {
4079            None
4080        }
4081    }
4082
4083    #[allow(irrefutable_let_patterns)]
4084    pub fn into_ready(self) -> Option<(u32, VirtioGpuReadyResponder)> {
4085        if let VirtioGpuRequest::Ready { negotiated_features, responder } = self {
4086            Some((negotiated_features, responder))
4087        } else {
4088            None
4089        }
4090    }
4091
4092    #[allow(irrefutable_let_patterns)]
4093    pub fn into_start(
4094        self,
4095    ) -> Option<(
4096        StartInfo,
4097        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
4098        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
4099        VirtioGpuStartResponder,
4100    )> {
4101        if let VirtioGpuRequest::Start { start_info, keyboard_listener, mouse_source, responder } =
4102            self
4103        {
4104            Some((start_info, keyboard_listener, mouse_source, responder))
4105        } else {
4106            None
4107        }
4108    }
4109
4110    /// Name of the method defined in FIDL
4111    pub fn method_name(&self) -> &'static str {
4112        match *self {
4113            VirtioGpuRequest::ConfigureQueue { .. } => "configure_queue",
4114            VirtioGpuRequest::NotifyQueue { .. } => "notify_queue",
4115            VirtioGpuRequest::Ready { .. } => "ready",
4116            VirtioGpuRequest::Start { .. } => "start",
4117        }
4118    }
4119}
4120
4121#[derive(Debug, Clone)]
4122pub struct VirtioGpuControlHandle {
4123    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4124}
4125
4126impl fidl::endpoints::ControlHandle for VirtioGpuControlHandle {
4127    fn shutdown(&self) {
4128        self.inner.shutdown()
4129    }
4130
4131    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4132        self.inner.shutdown_with_epitaph(status)
4133    }
4134
4135    fn is_closed(&self) -> bool {
4136        self.inner.channel().is_closed()
4137    }
4138    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4139        self.inner.channel().on_closed()
4140    }
4141
4142    #[cfg(target_os = "fuchsia")]
4143    fn signal_peer(
4144        &self,
4145        clear_mask: zx::Signals,
4146        set_mask: zx::Signals,
4147    ) -> Result<(), zx_status::Status> {
4148        use fidl::Peered;
4149        self.inner.channel().signal_peer(clear_mask, set_mask)
4150    }
4151}
4152
4153impl VirtioGpuControlHandle {
4154    pub fn send_on_config_changed(&self) -> Result<(), fidl::Error> {
4155        self.inner.send::<fidl::encoding::EmptyPayload>(
4156            (),
4157            0,
4158            0x1555f5b7c8444aa0,
4159            fidl::encoding::DynamicFlags::empty(),
4160        )
4161    }
4162}
4163
4164#[must_use = "FIDL methods require a response to be sent"]
4165#[derive(Debug)]
4166pub struct VirtioGpuConfigureQueueResponder {
4167    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4168    tx_id: u32,
4169}
4170
4171/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4172/// if the responder is dropped without sending a response, so that the client
4173/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4174impl std::ops::Drop for VirtioGpuConfigureQueueResponder {
4175    fn drop(&mut self) {
4176        self.control_handle.shutdown();
4177        // Safety: drops once, never accessed again
4178        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4179    }
4180}
4181
4182impl fidl::endpoints::Responder for VirtioGpuConfigureQueueResponder {
4183    type ControlHandle = VirtioGpuControlHandle;
4184
4185    fn control_handle(&self) -> &VirtioGpuControlHandle {
4186        &self.control_handle
4187    }
4188
4189    fn drop_without_shutdown(mut self) {
4190        // Safety: drops once, never accessed again due to mem::forget
4191        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4192        // Prevent Drop from running (which would shut down the channel)
4193        std::mem::forget(self);
4194    }
4195}
4196
4197impl VirtioGpuConfigureQueueResponder {
4198    /// Sends a response to the FIDL transaction.
4199    ///
4200    /// Sets the channel to shutdown if an error occurs.
4201    pub fn send(self) -> Result<(), fidl::Error> {
4202        let _result = self.send_raw();
4203        if _result.is_err() {
4204            self.control_handle.shutdown();
4205        }
4206        self.drop_without_shutdown();
4207        _result
4208    }
4209
4210    /// Similar to "send" but does not shutdown the channel if an error occurs.
4211    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4212        let _result = self.send_raw();
4213        self.drop_without_shutdown();
4214        _result
4215    }
4216
4217    fn send_raw(&self) -> Result<(), fidl::Error> {
4218        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4219            (),
4220            self.tx_id,
4221            0x72b44fb963480b11,
4222            fidl::encoding::DynamicFlags::empty(),
4223        )
4224    }
4225}
4226
4227#[must_use = "FIDL methods require a response to be sent"]
4228#[derive(Debug)]
4229pub struct VirtioGpuReadyResponder {
4230    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4231    tx_id: u32,
4232}
4233
4234/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4235/// if the responder is dropped without sending a response, so that the client
4236/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4237impl std::ops::Drop for VirtioGpuReadyResponder {
4238    fn drop(&mut self) {
4239        self.control_handle.shutdown();
4240        // Safety: drops once, never accessed again
4241        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4242    }
4243}
4244
4245impl fidl::endpoints::Responder for VirtioGpuReadyResponder {
4246    type ControlHandle = VirtioGpuControlHandle;
4247
4248    fn control_handle(&self) -> &VirtioGpuControlHandle {
4249        &self.control_handle
4250    }
4251
4252    fn drop_without_shutdown(mut self) {
4253        // Safety: drops once, never accessed again due to mem::forget
4254        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4255        // Prevent Drop from running (which would shut down the channel)
4256        std::mem::forget(self);
4257    }
4258}
4259
4260impl VirtioGpuReadyResponder {
4261    /// Sends a response to the FIDL transaction.
4262    ///
4263    /// Sets the channel to shutdown if an error occurs.
4264    pub fn send(self) -> Result<(), fidl::Error> {
4265        let _result = self.send_raw();
4266        if _result.is_err() {
4267            self.control_handle.shutdown();
4268        }
4269        self.drop_without_shutdown();
4270        _result
4271    }
4272
4273    /// Similar to "send" but does not shutdown the channel if an error occurs.
4274    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4275        let _result = self.send_raw();
4276        self.drop_without_shutdown();
4277        _result
4278    }
4279
4280    fn send_raw(&self) -> Result<(), fidl::Error> {
4281        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4282            (),
4283            self.tx_id,
4284            0x45707654f5d23c3f,
4285            fidl::encoding::DynamicFlags::empty(),
4286        )
4287    }
4288}
4289
4290#[must_use = "FIDL methods require a response to be sent"]
4291#[derive(Debug)]
4292pub struct VirtioGpuStartResponder {
4293    control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
4294    tx_id: u32,
4295}
4296
4297/// Set the the channel to be shutdown (see [`VirtioGpuControlHandle::shutdown`])
4298/// if the responder is dropped without sending a response, so that the client
4299/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4300impl std::ops::Drop for VirtioGpuStartResponder {
4301    fn drop(&mut self) {
4302        self.control_handle.shutdown();
4303        // Safety: drops once, never accessed again
4304        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4305    }
4306}
4307
4308impl fidl::endpoints::Responder for VirtioGpuStartResponder {
4309    type ControlHandle = VirtioGpuControlHandle;
4310
4311    fn control_handle(&self) -> &VirtioGpuControlHandle {
4312        &self.control_handle
4313    }
4314
4315    fn drop_without_shutdown(mut self) {
4316        // Safety: drops once, never accessed again due to mem::forget
4317        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4318        // Prevent Drop from running (which would shut down the channel)
4319        std::mem::forget(self);
4320    }
4321}
4322
4323impl VirtioGpuStartResponder {
4324    /// Sends a response to the FIDL transaction.
4325    ///
4326    /// Sets the channel to shutdown if an error occurs.
4327    pub fn send(self) -> Result<(), fidl::Error> {
4328        let _result = self.send_raw();
4329        if _result.is_err() {
4330            self.control_handle.shutdown();
4331        }
4332        self.drop_without_shutdown();
4333        _result
4334    }
4335
4336    /// Similar to "send" but does not shutdown the channel if an error occurs.
4337    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4338        let _result = self.send_raw();
4339        self.drop_without_shutdown();
4340        _result
4341    }
4342
4343    fn send_raw(&self) -> Result<(), fidl::Error> {
4344        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4345            (),
4346            self.tx_id,
4347            0x7e81ed410f770c14,
4348            fidl::encoding::DynamicFlags::empty(),
4349        )
4350    }
4351}
4352
4353#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4354pub struct VirtioInputMarker;
4355
4356impl fidl::endpoints::ProtocolMarker for VirtioInputMarker {
4357    type Proxy = VirtioInputProxy;
4358    type RequestStream = VirtioInputRequestStream;
4359    #[cfg(target_os = "fuchsia")]
4360    type SynchronousProxy = VirtioInputSynchronousProxy;
4361
4362    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioInput";
4363}
4364impl fidl::endpoints::DiscoverableProtocolMarker for VirtioInputMarker {}
4365
4366pub trait VirtioInputProxyInterface: Send + Sync {
4367    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4368    fn r#configure_queue(
4369        &self,
4370        queue: u16,
4371        size: u16,
4372        desc: u64,
4373        avail: u64,
4374        used: u64,
4375    ) -> Self::ConfigureQueueResponseFut;
4376    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
4377    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4378    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
4379    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4380    fn r#start(&self, start_info: StartInfo, input_type: InputType) -> Self::StartResponseFut;
4381}
4382#[derive(Debug)]
4383#[cfg(target_os = "fuchsia")]
4384pub struct VirtioInputSynchronousProxy {
4385    client: fidl::client::sync::Client,
4386}
4387
4388#[cfg(target_os = "fuchsia")]
4389impl fidl::endpoints::SynchronousProxy for VirtioInputSynchronousProxy {
4390    type Proxy = VirtioInputProxy;
4391    type Protocol = VirtioInputMarker;
4392
4393    fn from_channel(inner: fidl::Channel) -> Self {
4394        Self::new(inner)
4395    }
4396
4397    fn into_channel(self) -> fidl::Channel {
4398        self.client.into_channel()
4399    }
4400
4401    fn as_channel(&self) -> &fidl::Channel {
4402        self.client.as_channel()
4403    }
4404}
4405
4406#[cfg(target_os = "fuchsia")]
4407impl VirtioInputSynchronousProxy {
4408    pub fn new(channel: fidl::Channel) -> Self {
4409        Self { client: fidl::client::sync::Client::new(channel) }
4410    }
4411
4412    pub fn into_channel(self) -> fidl::Channel {
4413        self.client.into_channel()
4414    }
4415
4416    /// Waits until an event arrives and returns it. It is safe for other
4417    /// threads to make concurrent requests while waiting for an event.
4418    pub fn wait_for_event(
4419        &self,
4420        deadline: zx::MonotonicInstant,
4421    ) -> Result<VirtioInputEvent, fidl::Error> {
4422        VirtioInputEvent::decode(self.client.wait_for_event::<VirtioInputMarker>(deadline)?)
4423    }
4424
4425    /// Configure a `queue` for the device. This specifies the `size` and the
4426    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4427    pub fn r#configure_queue(
4428        &self,
4429        mut queue: u16,
4430        mut size: u16,
4431        mut desc: u64,
4432        mut avail: u64,
4433        mut used: u64,
4434        ___deadline: zx::MonotonicInstant,
4435    ) -> Result<(), fidl::Error> {
4436        let _response = self.client.send_query::<
4437            VirtioDeviceConfigureQueueRequest,
4438            fidl::encoding::EmptyPayload,
4439            VirtioInputMarker,
4440        >(
4441            (queue, size, desc, avail, used,),
4442            0x72b44fb963480b11,
4443            fidl::encoding::DynamicFlags::empty(),
4444            ___deadline,
4445        )?;
4446        Ok(_response)
4447    }
4448
4449    /// Notify a `queue` for the device. Primarily used for black-box testing.
4450    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4451        self.client.send::<VirtioDeviceNotifyQueueRequest>(
4452            (queue,),
4453            0x6e3a61d652499244,
4454            fidl::encoding::DynamicFlags::empty(),
4455        )
4456    }
4457
4458    /// Ready a device. This provides the set of `negotiated_features` that the
4459    /// driver and device have agreed upon.
4460    pub fn r#ready(
4461        &self,
4462        mut negotiated_features: u32,
4463        ___deadline: zx::MonotonicInstant,
4464    ) -> Result<(), fidl::Error> {
4465        let _response = self.client.send_query::<
4466            VirtioDeviceReadyRequest,
4467            fidl::encoding::EmptyPayload,
4468            VirtioInputMarker,
4469        >(
4470            (negotiated_features,),
4471            0x45707654f5d23c3f,
4472            fidl::encoding::DynamicFlags::empty(),
4473            ___deadline,
4474        )?;
4475        Ok(_response)
4476    }
4477
4478    /// Start the input device.
4479    pub fn r#start(
4480        &self,
4481        mut start_info: StartInfo,
4482        mut input_type: InputType,
4483        ___deadline: zx::MonotonicInstant,
4484    ) -> Result<(), fidl::Error> {
4485        let _response = self
4486            .client
4487            .send_query::<VirtioInputStartRequest, fidl::encoding::EmptyPayload, VirtioInputMarker>(
4488                (&mut start_info, &mut input_type),
4489                0x612743931f7f9249,
4490                fidl::encoding::DynamicFlags::empty(),
4491                ___deadline,
4492            )?;
4493        Ok(_response)
4494    }
4495}
4496
4497#[cfg(target_os = "fuchsia")]
4498impl From<VirtioInputSynchronousProxy> for zx::NullableHandle {
4499    fn from(value: VirtioInputSynchronousProxy) -> Self {
4500        value.into_channel().into()
4501    }
4502}
4503
4504#[cfg(target_os = "fuchsia")]
4505impl From<fidl::Channel> for VirtioInputSynchronousProxy {
4506    fn from(value: fidl::Channel) -> Self {
4507        Self::new(value)
4508    }
4509}
4510
4511#[cfg(target_os = "fuchsia")]
4512impl fidl::endpoints::FromClient for VirtioInputSynchronousProxy {
4513    type Protocol = VirtioInputMarker;
4514
4515    fn from_client(value: fidl::endpoints::ClientEnd<VirtioInputMarker>) -> Self {
4516        Self::new(value.into_channel())
4517    }
4518}
4519
4520#[derive(Debug, Clone)]
4521pub struct VirtioInputProxy {
4522    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4523}
4524
4525impl fidl::endpoints::Proxy for VirtioInputProxy {
4526    type Protocol = VirtioInputMarker;
4527
4528    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4529        Self::new(inner)
4530    }
4531
4532    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4533        self.client.into_channel().map_err(|client| Self { client })
4534    }
4535
4536    fn as_channel(&self) -> &::fidl::AsyncChannel {
4537        self.client.as_channel()
4538    }
4539}
4540
4541impl VirtioInputProxy {
4542    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioInput.
4543    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4544        let protocol_name = <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4545        Self { client: fidl::client::Client::new(channel, protocol_name) }
4546    }
4547
4548    /// Get a Stream of events from the remote end of the protocol.
4549    ///
4550    /// # Panics
4551    ///
4552    /// Panics if the event stream was already taken.
4553    pub fn take_event_stream(&self) -> VirtioInputEventStream {
4554        VirtioInputEventStream { event_receiver: self.client.take_event_receiver() }
4555    }
4556
4557    /// Configure a `queue` for the device. This specifies the `size` and the
4558    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4559    pub fn r#configure_queue(
4560        &self,
4561        mut queue: u16,
4562        mut size: u16,
4563        mut desc: u64,
4564        mut avail: u64,
4565        mut used: u64,
4566    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4567        VirtioInputProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
4568    }
4569
4570    /// Notify a `queue` for the device. Primarily used for black-box testing.
4571    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4572        VirtioInputProxyInterface::r#notify_queue(self, queue)
4573    }
4574
4575    /// Ready a device. This provides the set of `negotiated_features` that the
4576    /// driver and device have agreed upon.
4577    pub fn r#ready(
4578        &self,
4579        mut negotiated_features: u32,
4580    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4581        VirtioInputProxyInterface::r#ready(self, negotiated_features)
4582    }
4583
4584    /// Start the input device.
4585    pub fn r#start(
4586        &self,
4587        mut start_info: StartInfo,
4588        mut input_type: InputType,
4589    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4590        VirtioInputProxyInterface::r#start(self, start_info, input_type)
4591    }
4592}
4593
4594impl VirtioInputProxyInterface for VirtioInputProxy {
4595    type ConfigureQueueResponseFut =
4596        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4597    fn r#configure_queue(
4598        &self,
4599        mut queue: u16,
4600        mut size: u16,
4601        mut desc: u64,
4602        mut avail: u64,
4603        mut used: u64,
4604    ) -> Self::ConfigureQueueResponseFut {
4605        fn _decode(
4606            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4607        ) -> Result<(), fidl::Error> {
4608            let _response = fidl::client::decode_transaction_body::<
4609                fidl::encoding::EmptyPayload,
4610                fidl::encoding::DefaultFuchsiaResourceDialect,
4611                0x72b44fb963480b11,
4612            >(_buf?)?;
4613            Ok(_response)
4614        }
4615        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
4616            (queue, size, desc, avail, used),
4617            0x72b44fb963480b11,
4618            fidl::encoding::DynamicFlags::empty(),
4619            _decode,
4620        )
4621    }
4622
4623    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
4624        self.client.send::<VirtioDeviceNotifyQueueRequest>(
4625            (queue,),
4626            0x6e3a61d652499244,
4627            fidl::encoding::DynamicFlags::empty(),
4628        )
4629    }
4630
4631    type ReadyResponseFut =
4632        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4633    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
4634        fn _decode(
4635            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4636        ) -> Result<(), fidl::Error> {
4637            let _response = fidl::client::decode_transaction_body::<
4638                fidl::encoding::EmptyPayload,
4639                fidl::encoding::DefaultFuchsiaResourceDialect,
4640                0x45707654f5d23c3f,
4641            >(_buf?)?;
4642            Ok(_response)
4643        }
4644        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
4645            (negotiated_features,),
4646            0x45707654f5d23c3f,
4647            fidl::encoding::DynamicFlags::empty(),
4648            _decode,
4649        )
4650    }
4651
4652    type StartResponseFut =
4653        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4654    fn r#start(
4655        &self,
4656        mut start_info: StartInfo,
4657        mut input_type: InputType,
4658    ) -> Self::StartResponseFut {
4659        fn _decode(
4660            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4661        ) -> Result<(), fidl::Error> {
4662            let _response = fidl::client::decode_transaction_body::<
4663                fidl::encoding::EmptyPayload,
4664                fidl::encoding::DefaultFuchsiaResourceDialect,
4665                0x612743931f7f9249,
4666            >(_buf?)?;
4667            Ok(_response)
4668        }
4669        self.client.send_query_and_decode::<VirtioInputStartRequest, ()>(
4670            (&mut start_info, &mut input_type),
4671            0x612743931f7f9249,
4672            fidl::encoding::DynamicFlags::empty(),
4673            _decode,
4674        )
4675    }
4676}
4677
4678pub struct VirtioInputEventStream {
4679    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4680}
4681
4682impl std::marker::Unpin for VirtioInputEventStream {}
4683
4684impl futures::stream::FusedStream for VirtioInputEventStream {
4685    fn is_terminated(&self) -> bool {
4686        self.event_receiver.is_terminated()
4687    }
4688}
4689
4690impl futures::Stream for VirtioInputEventStream {
4691    type Item = Result<VirtioInputEvent, fidl::Error>;
4692
4693    fn poll_next(
4694        mut self: std::pin::Pin<&mut Self>,
4695        cx: &mut std::task::Context<'_>,
4696    ) -> std::task::Poll<Option<Self::Item>> {
4697        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4698            &mut self.event_receiver,
4699            cx
4700        )?) {
4701            Some(buf) => std::task::Poll::Ready(Some(VirtioInputEvent::decode(buf))),
4702            None => std::task::Poll::Ready(None),
4703        }
4704    }
4705}
4706
4707#[derive(Debug)]
4708pub enum VirtioInputEvent {}
4709
4710impl VirtioInputEvent {
4711    /// Decodes a message buffer as a [`VirtioInputEvent`].
4712    fn decode(
4713        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4714    ) -> Result<VirtioInputEvent, fidl::Error> {
4715        let (bytes, _handles) = buf.split_mut();
4716        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4717        debug_assert_eq!(tx_header.tx_id, 0);
4718        match tx_header.ordinal {
4719            _ => Err(fidl::Error::UnknownOrdinal {
4720                ordinal: tx_header.ordinal,
4721                protocol_name: <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4722            }),
4723        }
4724    }
4725}
4726
4727/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioInput.
4728pub struct VirtioInputRequestStream {
4729    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4730    is_terminated: bool,
4731}
4732
4733impl std::marker::Unpin for VirtioInputRequestStream {}
4734
4735impl futures::stream::FusedStream for VirtioInputRequestStream {
4736    fn is_terminated(&self) -> bool {
4737        self.is_terminated
4738    }
4739}
4740
4741impl fidl::endpoints::RequestStream for VirtioInputRequestStream {
4742    type Protocol = VirtioInputMarker;
4743    type ControlHandle = VirtioInputControlHandle;
4744
4745    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4746        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4747    }
4748
4749    fn control_handle(&self) -> Self::ControlHandle {
4750        VirtioInputControlHandle { inner: self.inner.clone() }
4751    }
4752
4753    fn into_inner(
4754        self,
4755    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4756    {
4757        (self.inner, self.is_terminated)
4758    }
4759
4760    fn from_inner(
4761        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4762        is_terminated: bool,
4763    ) -> Self {
4764        Self { inner, is_terminated }
4765    }
4766}
4767
4768impl futures::Stream for VirtioInputRequestStream {
4769    type Item = Result<VirtioInputRequest, fidl::Error>;
4770
4771    fn poll_next(
4772        mut self: std::pin::Pin<&mut Self>,
4773        cx: &mut std::task::Context<'_>,
4774    ) -> std::task::Poll<Option<Self::Item>> {
4775        let this = &mut *self;
4776        if this.inner.check_shutdown(cx) {
4777            this.is_terminated = true;
4778            return std::task::Poll::Ready(None);
4779        }
4780        if this.is_terminated {
4781            panic!("polled VirtioInputRequestStream after completion");
4782        }
4783        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4784            |bytes, handles| {
4785                match this.inner.channel().read_etc(cx, bytes, handles) {
4786                    std::task::Poll::Ready(Ok(())) => {}
4787                    std::task::Poll::Pending => return std::task::Poll::Pending,
4788                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4789                        this.is_terminated = true;
4790                        return std::task::Poll::Ready(None);
4791                    }
4792                    std::task::Poll::Ready(Err(e)) => {
4793                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4794                            e.into(),
4795                        ))));
4796                    }
4797                }
4798
4799                // A message has been received from the channel
4800                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4801
4802                std::task::Poll::Ready(Some(match header.ordinal {
4803                    0x72b44fb963480b11 => {
4804                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4805                        let mut req = fidl::new_empty!(
4806                            VirtioDeviceConfigureQueueRequest,
4807                            fidl::encoding::DefaultFuchsiaResourceDialect
4808                        );
4809                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
4810                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4811                        Ok(VirtioInputRequest::ConfigureQueue {
4812                            queue: req.queue,
4813                            size: req.size,
4814                            desc: req.desc,
4815                            avail: req.avail,
4816                            used: req.used,
4817
4818                            responder: VirtioInputConfigureQueueResponder {
4819                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4820                                tx_id: header.tx_id,
4821                            },
4822                        })
4823                    }
4824                    0x6e3a61d652499244 => {
4825                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4826                        let mut req = fidl::new_empty!(
4827                            VirtioDeviceNotifyQueueRequest,
4828                            fidl::encoding::DefaultFuchsiaResourceDialect
4829                        );
4830                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
4831                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4832                        Ok(VirtioInputRequest::NotifyQueue { queue: req.queue, control_handle })
4833                    }
4834                    0x45707654f5d23c3f => {
4835                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4836                        let mut req = fidl::new_empty!(
4837                            VirtioDeviceReadyRequest,
4838                            fidl::encoding::DefaultFuchsiaResourceDialect
4839                        );
4840                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
4841                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4842                        Ok(VirtioInputRequest::Ready {
4843                            negotiated_features: req.negotiated_features,
4844
4845                            responder: VirtioInputReadyResponder {
4846                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4847                                tx_id: header.tx_id,
4848                            },
4849                        })
4850                    }
4851                    0x612743931f7f9249 => {
4852                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4853                        let mut req = fidl::new_empty!(
4854                            VirtioInputStartRequest,
4855                            fidl::encoding::DefaultFuchsiaResourceDialect
4856                        );
4857                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioInputStartRequest>(&header, _body_bytes, handles, &mut req)?;
4858                        let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
4859                        Ok(VirtioInputRequest::Start {
4860                            start_info: req.start_info,
4861                            input_type: req.input_type,
4862
4863                            responder: VirtioInputStartResponder {
4864                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4865                                tx_id: header.tx_id,
4866                            },
4867                        })
4868                    }
4869                    _ => Err(fidl::Error::UnknownOrdinal {
4870                        ordinal: header.ordinal,
4871                        protocol_name:
4872                            <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4873                    }),
4874                }))
4875            },
4876        )
4877    }
4878}
4879
4880#[derive(Debug)]
4881pub enum VirtioInputRequest {
4882    /// Configure a `queue` for the device. This specifies the `size` and the
4883    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
4884    ConfigureQueue {
4885        queue: u16,
4886        size: u16,
4887        desc: u64,
4888        avail: u64,
4889        used: u64,
4890        responder: VirtioInputConfigureQueueResponder,
4891    },
4892    /// Notify a `queue` for the device. Primarily used for black-box testing.
4893    NotifyQueue { queue: u16, control_handle: VirtioInputControlHandle },
4894    /// Ready a device. This provides the set of `negotiated_features` that the
4895    /// driver and device have agreed upon.
4896    Ready { negotiated_features: u32, responder: VirtioInputReadyResponder },
4897    /// Start the input device.
4898    Start { start_info: StartInfo, input_type: InputType, responder: VirtioInputStartResponder },
4899}
4900
4901impl VirtioInputRequest {
4902    #[allow(irrefutable_let_patterns)]
4903    pub fn into_configure_queue(
4904        self,
4905    ) -> Option<(u16, u16, u64, u64, u64, VirtioInputConfigureQueueResponder)> {
4906        if let VirtioInputRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
4907            self
4908        {
4909            Some((queue, size, desc, avail, used, responder))
4910        } else {
4911            None
4912        }
4913    }
4914
4915    #[allow(irrefutable_let_patterns)]
4916    pub fn into_notify_queue(self) -> Option<(u16, VirtioInputControlHandle)> {
4917        if let VirtioInputRequest::NotifyQueue { queue, control_handle } = self {
4918            Some((queue, control_handle))
4919        } else {
4920            None
4921        }
4922    }
4923
4924    #[allow(irrefutable_let_patterns)]
4925    pub fn into_ready(self) -> Option<(u32, VirtioInputReadyResponder)> {
4926        if let VirtioInputRequest::Ready { negotiated_features, responder } = self {
4927            Some((negotiated_features, responder))
4928        } else {
4929            None
4930        }
4931    }
4932
4933    #[allow(irrefutable_let_patterns)]
4934    pub fn into_start(self) -> Option<(StartInfo, InputType, VirtioInputStartResponder)> {
4935        if let VirtioInputRequest::Start { start_info, input_type, responder } = self {
4936            Some((start_info, input_type, responder))
4937        } else {
4938            None
4939        }
4940    }
4941
4942    /// Name of the method defined in FIDL
4943    pub fn method_name(&self) -> &'static str {
4944        match *self {
4945            VirtioInputRequest::ConfigureQueue { .. } => "configure_queue",
4946            VirtioInputRequest::NotifyQueue { .. } => "notify_queue",
4947            VirtioInputRequest::Ready { .. } => "ready",
4948            VirtioInputRequest::Start { .. } => "start",
4949        }
4950    }
4951}
4952
4953#[derive(Debug, Clone)]
4954pub struct VirtioInputControlHandle {
4955    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4956}
4957
4958impl fidl::endpoints::ControlHandle for VirtioInputControlHandle {
4959    fn shutdown(&self) {
4960        self.inner.shutdown()
4961    }
4962
4963    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4964        self.inner.shutdown_with_epitaph(status)
4965    }
4966
4967    fn is_closed(&self) -> bool {
4968        self.inner.channel().is_closed()
4969    }
4970    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4971        self.inner.channel().on_closed()
4972    }
4973
4974    #[cfg(target_os = "fuchsia")]
4975    fn signal_peer(
4976        &self,
4977        clear_mask: zx::Signals,
4978        set_mask: zx::Signals,
4979    ) -> Result<(), zx_status::Status> {
4980        use fidl::Peered;
4981        self.inner.channel().signal_peer(clear_mask, set_mask)
4982    }
4983}
4984
4985impl VirtioInputControlHandle {}
4986
4987#[must_use = "FIDL methods require a response to be sent"]
4988#[derive(Debug)]
4989pub struct VirtioInputConfigureQueueResponder {
4990    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
4991    tx_id: u32,
4992}
4993
4994/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
4995/// if the responder is dropped without sending a response, so that the client
4996/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4997impl std::ops::Drop for VirtioInputConfigureQueueResponder {
4998    fn drop(&mut self) {
4999        self.control_handle.shutdown();
5000        // Safety: drops once, never accessed again
5001        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5002    }
5003}
5004
5005impl fidl::endpoints::Responder for VirtioInputConfigureQueueResponder {
5006    type ControlHandle = VirtioInputControlHandle;
5007
5008    fn control_handle(&self) -> &VirtioInputControlHandle {
5009        &self.control_handle
5010    }
5011
5012    fn drop_without_shutdown(mut self) {
5013        // Safety: drops once, never accessed again due to mem::forget
5014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5015        // Prevent Drop from running (which would shut down the channel)
5016        std::mem::forget(self);
5017    }
5018}
5019
5020impl VirtioInputConfigureQueueResponder {
5021    /// Sends a response to the FIDL transaction.
5022    ///
5023    /// Sets the channel to shutdown if an error occurs.
5024    pub fn send(self) -> Result<(), fidl::Error> {
5025        let _result = self.send_raw();
5026        if _result.is_err() {
5027            self.control_handle.shutdown();
5028        }
5029        self.drop_without_shutdown();
5030        _result
5031    }
5032
5033    /// Similar to "send" but does not shutdown the channel if an error occurs.
5034    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5035        let _result = self.send_raw();
5036        self.drop_without_shutdown();
5037        _result
5038    }
5039
5040    fn send_raw(&self) -> Result<(), fidl::Error> {
5041        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5042            (),
5043            self.tx_id,
5044            0x72b44fb963480b11,
5045            fidl::encoding::DynamicFlags::empty(),
5046        )
5047    }
5048}
5049
5050#[must_use = "FIDL methods require a response to be sent"]
5051#[derive(Debug)]
5052pub struct VirtioInputReadyResponder {
5053    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
5054    tx_id: u32,
5055}
5056
5057/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
5058/// if the responder is dropped without sending a response, so that the client
5059/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5060impl std::ops::Drop for VirtioInputReadyResponder {
5061    fn drop(&mut self) {
5062        self.control_handle.shutdown();
5063        // Safety: drops once, never accessed again
5064        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5065    }
5066}
5067
5068impl fidl::endpoints::Responder for VirtioInputReadyResponder {
5069    type ControlHandle = VirtioInputControlHandle;
5070
5071    fn control_handle(&self) -> &VirtioInputControlHandle {
5072        &self.control_handle
5073    }
5074
5075    fn drop_without_shutdown(mut self) {
5076        // Safety: drops once, never accessed again due to mem::forget
5077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5078        // Prevent Drop from running (which would shut down the channel)
5079        std::mem::forget(self);
5080    }
5081}
5082
5083impl VirtioInputReadyResponder {
5084    /// Sends a response to the FIDL transaction.
5085    ///
5086    /// Sets the channel to shutdown if an error occurs.
5087    pub fn send(self) -> Result<(), fidl::Error> {
5088        let _result = self.send_raw();
5089        if _result.is_err() {
5090            self.control_handle.shutdown();
5091        }
5092        self.drop_without_shutdown();
5093        _result
5094    }
5095
5096    /// Similar to "send" but does not shutdown the channel if an error occurs.
5097    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5098        let _result = self.send_raw();
5099        self.drop_without_shutdown();
5100        _result
5101    }
5102
5103    fn send_raw(&self) -> Result<(), fidl::Error> {
5104        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5105            (),
5106            self.tx_id,
5107            0x45707654f5d23c3f,
5108            fidl::encoding::DynamicFlags::empty(),
5109        )
5110    }
5111}
5112
5113#[must_use = "FIDL methods require a response to be sent"]
5114#[derive(Debug)]
5115pub struct VirtioInputStartResponder {
5116    control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
5117    tx_id: u32,
5118}
5119
5120/// Set the the channel to be shutdown (see [`VirtioInputControlHandle::shutdown`])
5121/// if the responder is dropped without sending a response, so that the client
5122/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5123impl std::ops::Drop for VirtioInputStartResponder {
5124    fn drop(&mut self) {
5125        self.control_handle.shutdown();
5126        // Safety: drops once, never accessed again
5127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5128    }
5129}
5130
5131impl fidl::endpoints::Responder for VirtioInputStartResponder {
5132    type ControlHandle = VirtioInputControlHandle;
5133
5134    fn control_handle(&self) -> &VirtioInputControlHandle {
5135        &self.control_handle
5136    }
5137
5138    fn drop_without_shutdown(mut self) {
5139        // Safety: drops once, never accessed again due to mem::forget
5140        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5141        // Prevent Drop from running (which would shut down the channel)
5142        std::mem::forget(self);
5143    }
5144}
5145
5146impl VirtioInputStartResponder {
5147    /// Sends a response to the FIDL transaction.
5148    ///
5149    /// Sets the channel to shutdown if an error occurs.
5150    pub fn send(self) -> Result<(), fidl::Error> {
5151        let _result = self.send_raw();
5152        if _result.is_err() {
5153            self.control_handle.shutdown();
5154        }
5155        self.drop_without_shutdown();
5156        _result
5157    }
5158
5159    /// Similar to "send" but does not shutdown the channel if an error occurs.
5160    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5161        let _result = self.send_raw();
5162        self.drop_without_shutdown();
5163        _result
5164    }
5165
5166    fn send_raw(&self) -> Result<(), fidl::Error> {
5167        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5168            (),
5169            self.tx_id,
5170            0x612743931f7f9249,
5171            fidl::encoding::DynamicFlags::empty(),
5172        )
5173    }
5174}
5175
5176#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5177pub struct VirtioMemMarker;
5178
5179impl fidl::endpoints::ProtocolMarker for VirtioMemMarker {
5180    type Proxy = VirtioMemProxy;
5181    type RequestStream = VirtioMemRequestStream;
5182    #[cfg(target_os = "fuchsia")]
5183    type SynchronousProxy = VirtioMemSynchronousProxy;
5184
5185    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioMem";
5186}
5187impl fidl::endpoints::DiscoverableProtocolMarker for VirtioMemMarker {}
5188
5189pub trait VirtioMemProxyInterface: Send + Sync {
5190    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5191    fn r#configure_queue(
5192        &self,
5193        queue: u16,
5194        size: u16,
5195        desc: u64,
5196        avail: u64,
5197        used: u64,
5198    ) -> Self::ConfigureQueueResponseFut;
5199    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
5200    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5201    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
5202    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5203    fn r#start(
5204        &self,
5205        start_info: StartInfo,
5206        region_addr: u64,
5207        plugged_block_size: u64,
5208        region_size: u64,
5209    ) -> Self::StartResponseFut;
5210}
5211#[derive(Debug)]
5212#[cfg(target_os = "fuchsia")]
5213pub struct VirtioMemSynchronousProxy {
5214    client: fidl::client::sync::Client,
5215}
5216
5217#[cfg(target_os = "fuchsia")]
5218impl fidl::endpoints::SynchronousProxy for VirtioMemSynchronousProxy {
5219    type Proxy = VirtioMemProxy;
5220    type Protocol = VirtioMemMarker;
5221
5222    fn from_channel(inner: fidl::Channel) -> Self {
5223        Self::new(inner)
5224    }
5225
5226    fn into_channel(self) -> fidl::Channel {
5227        self.client.into_channel()
5228    }
5229
5230    fn as_channel(&self) -> &fidl::Channel {
5231        self.client.as_channel()
5232    }
5233}
5234
5235#[cfg(target_os = "fuchsia")]
5236impl VirtioMemSynchronousProxy {
5237    pub fn new(channel: fidl::Channel) -> Self {
5238        Self { client: fidl::client::sync::Client::new(channel) }
5239    }
5240
5241    pub fn into_channel(self) -> fidl::Channel {
5242        self.client.into_channel()
5243    }
5244
5245    /// Waits until an event arrives and returns it. It is safe for other
5246    /// threads to make concurrent requests while waiting for an event.
5247    pub fn wait_for_event(
5248        &self,
5249        deadline: zx::MonotonicInstant,
5250    ) -> Result<VirtioMemEvent, fidl::Error> {
5251        VirtioMemEvent::decode(self.client.wait_for_event::<VirtioMemMarker>(deadline)?)
5252    }
5253
5254    /// Configure a `queue` for the device. This specifies the `size` and the
5255    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5256    pub fn r#configure_queue(
5257        &self,
5258        mut queue: u16,
5259        mut size: u16,
5260        mut desc: u64,
5261        mut avail: u64,
5262        mut used: u64,
5263        ___deadline: zx::MonotonicInstant,
5264    ) -> Result<(), fidl::Error> {
5265        let _response = self.client.send_query::<
5266            VirtioDeviceConfigureQueueRequest,
5267            fidl::encoding::EmptyPayload,
5268            VirtioMemMarker,
5269        >(
5270            (queue, size, desc, avail, used,),
5271            0x72b44fb963480b11,
5272            fidl::encoding::DynamicFlags::empty(),
5273            ___deadline,
5274        )?;
5275        Ok(_response)
5276    }
5277
5278    /// Notify a `queue` for the device. Primarily used for black-box testing.
5279    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5280        self.client.send::<VirtioDeviceNotifyQueueRequest>(
5281            (queue,),
5282            0x6e3a61d652499244,
5283            fidl::encoding::DynamicFlags::empty(),
5284        )
5285    }
5286
5287    /// Ready a device. This provides the set of `negotiated_features` that the
5288    /// driver and device have agreed upon.
5289    pub fn r#ready(
5290        &self,
5291        mut negotiated_features: u32,
5292        ___deadline: zx::MonotonicInstant,
5293    ) -> Result<(), fidl::Error> {
5294        let _response = self
5295            .client
5296            .send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload, VirtioMemMarker>(
5297                (negotiated_features,),
5298                0x45707654f5d23c3f,
5299                fidl::encoding::DynamicFlags::empty(),
5300                ___deadline,
5301            )?;
5302        Ok(_response)
5303    }
5304
5305    /// Start the mem device.
5306    pub fn r#start(
5307        &self,
5308        mut start_info: StartInfo,
5309        mut region_addr: u64,
5310        mut plugged_block_size: u64,
5311        mut region_size: u64,
5312        ___deadline: zx::MonotonicInstant,
5313    ) -> Result<(), fidl::Error> {
5314        let _response = self
5315            .client
5316            .send_query::<VirtioMemStartRequest, fidl::encoding::EmptyPayload, VirtioMemMarker>(
5317                (&mut start_info, region_addr, plugged_block_size, region_size),
5318                0x66dd64f17fb5223c,
5319                fidl::encoding::DynamicFlags::empty(),
5320                ___deadline,
5321            )?;
5322        Ok(_response)
5323    }
5324}
5325
5326#[cfg(target_os = "fuchsia")]
5327impl From<VirtioMemSynchronousProxy> for zx::NullableHandle {
5328    fn from(value: VirtioMemSynchronousProxy) -> Self {
5329        value.into_channel().into()
5330    }
5331}
5332
5333#[cfg(target_os = "fuchsia")]
5334impl From<fidl::Channel> for VirtioMemSynchronousProxy {
5335    fn from(value: fidl::Channel) -> Self {
5336        Self::new(value)
5337    }
5338}
5339
5340#[cfg(target_os = "fuchsia")]
5341impl fidl::endpoints::FromClient for VirtioMemSynchronousProxy {
5342    type Protocol = VirtioMemMarker;
5343
5344    fn from_client(value: fidl::endpoints::ClientEnd<VirtioMemMarker>) -> Self {
5345        Self::new(value.into_channel())
5346    }
5347}
5348
5349#[derive(Debug, Clone)]
5350pub struct VirtioMemProxy {
5351    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5352}
5353
5354impl fidl::endpoints::Proxy for VirtioMemProxy {
5355    type Protocol = VirtioMemMarker;
5356
5357    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5358        Self::new(inner)
5359    }
5360
5361    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5362        self.client.into_channel().map_err(|client| Self { client })
5363    }
5364
5365    fn as_channel(&self) -> &::fidl::AsyncChannel {
5366        self.client.as_channel()
5367    }
5368}
5369
5370impl VirtioMemProxy {
5371    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioMem.
5372    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5373        let protocol_name = <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5374        Self { client: fidl::client::Client::new(channel, protocol_name) }
5375    }
5376
5377    /// Get a Stream of events from the remote end of the protocol.
5378    ///
5379    /// # Panics
5380    ///
5381    /// Panics if the event stream was already taken.
5382    pub fn take_event_stream(&self) -> VirtioMemEventStream {
5383        VirtioMemEventStream { event_receiver: self.client.take_event_receiver() }
5384    }
5385
5386    /// Configure a `queue` for the device. This specifies the `size` and the
5387    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5388    pub fn r#configure_queue(
5389        &self,
5390        mut queue: u16,
5391        mut size: u16,
5392        mut desc: u64,
5393        mut avail: u64,
5394        mut used: u64,
5395    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5396        VirtioMemProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
5397    }
5398
5399    /// Notify a `queue` for the device. Primarily used for black-box testing.
5400    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5401        VirtioMemProxyInterface::r#notify_queue(self, queue)
5402    }
5403
5404    /// Ready a device. This provides the set of `negotiated_features` that the
5405    /// driver and device have agreed upon.
5406    pub fn r#ready(
5407        &self,
5408        mut negotiated_features: u32,
5409    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5410        VirtioMemProxyInterface::r#ready(self, negotiated_features)
5411    }
5412
5413    /// Start the mem device.
5414    pub fn r#start(
5415        &self,
5416        mut start_info: StartInfo,
5417        mut region_addr: u64,
5418        mut plugged_block_size: u64,
5419        mut region_size: u64,
5420    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5421        VirtioMemProxyInterface::r#start(
5422            self,
5423            start_info,
5424            region_addr,
5425            plugged_block_size,
5426            region_size,
5427        )
5428    }
5429}
5430
5431impl VirtioMemProxyInterface for VirtioMemProxy {
5432    type ConfigureQueueResponseFut =
5433        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5434    fn r#configure_queue(
5435        &self,
5436        mut queue: u16,
5437        mut size: u16,
5438        mut desc: u64,
5439        mut avail: u64,
5440        mut used: u64,
5441    ) -> Self::ConfigureQueueResponseFut {
5442        fn _decode(
5443            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5444        ) -> Result<(), fidl::Error> {
5445            let _response = fidl::client::decode_transaction_body::<
5446                fidl::encoding::EmptyPayload,
5447                fidl::encoding::DefaultFuchsiaResourceDialect,
5448                0x72b44fb963480b11,
5449            >(_buf?)?;
5450            Ok(_response)
5451        }
5452        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
5453            (queue, size, desc, avail, used),
5454            0x72b44fb963480b11,
5455            fidl::encoding::DynamicFlags::empty(),
5456            _decode,
5457        )
5458    }
5459
5460    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
5461        self.client.send::<VirtioDeviceNotifyQueueRequest>(
5462            (queue,),
5463            0x6e3a61d652499244,
5464            fidl::encoding::DynamicFlags::empty(),
5465        )
5466    }
5467
5468    type ReadyResponseFut =
5469        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5470    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
5471        fn _decode(
5472            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5473        ) -> Result<(), fidl::Error> {
5474            let _response = fidl::client::decode_transaction_body::<
5475                fidl::encoding::EmptyPayload,
5476                fidl::encoding::DefaultFuchsiaResourceDialect,
5477                0x45707654f5d23c3f,
5478            >(_buf?)?;
5479            Ok(_response)
5480        }
5481        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
5482            (negotiated_features,),
5483            0x45707654f5d23c3f,
5484            fidl::encoding::DynamicFlags::empty(),
5485            _decode,
5486        )
5487    }
5488
5489    type StartResponseFut =
5490        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5491    fn r#start(
5492        &self,
5493        mut start_info: StartInfo,
5494        mut region_addr: u64,
5495        mut plugged_block_size: u64,
5496        mut region_size: u64,
5497    ) -> Self::StartResponseFut {
5498        fn _decode(
5499            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5500        ) -> Result<(), fidl::Error> {
5501            let _response = fidl::client::decode_transaction_body::<
5502                fidl::encoding::EmptyPayload,
5503                fidl::encoding::DefaultFuchsiaResourceDialect,
5504                0x66dd64f17fb5223c,
5505            >(_buf?)?;
5506            Ok(_response)
5507        }
5508        self.client.send_query_and_decode::<VirtioMemStartRequest, ()>(
5509            (&mut start_info, region_addr, plugged_block_size, region_size),
5510            0x66dd64f17fb5223c,
5511            fidl::encoding::DynamicFlags::empty(),
5512            _decode,
5513        )
5514    }
5515}
5516
5517pub struct VirtioMemEventStream {
5518    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5519}
5520
5521impl std::marker::Unpin for VirtioMemEventStream {}
5522
5523impl futures::stream::FusedStream for VirtioMemEventStream {
5524    fn is_terminated(&self) -> bool {
5525        self.event_receiver.is_terminated()
5526    }
5527}
5528
5529impl futures::Stream for VirtioMemEventStream {
5530    type Item = Result<VirtioMemEvent, fidl::Error>;
5531
5532    fn poll_next(
5533        mut self: std::pin::Pin<&mut Self>,
5534        cx: &mut std::task::Context<'_>,
5535    ) -> std::task::Poll<Option<Self::Item>> {
5536        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5537            &mut self.event_receiver,
5538            cx
5539        )?) {
5540            Some(buf) => std::task::Poll::Ready(Some(VirtioMemEvent::decode(buf))),
5541            None => std::task::Poll::Ready(None),
5542        }
5543    }
5544}
5545
5546#[derive(Debug)]
5547pub enum VirtioMemEvent {
5548    OnConfigChanged { plugged_size: u64 },
5549}
5550
5551impl VirtioMemEvent {
5552    #[allow(irrefutable_let_patterns)]
5553    pub fn into_on_config_changed(self) -> Option<u64> {
5554        if let VirtioMemEvent::OnConfigChanged { plugged_size } = self {
5555            Some((plugged_size))
5556        } else {
5557            None
5558        }
5559    }
5560
5561    /// Decodes a message buffer as a [`VirtioMemEvent`].
5562    fn decode(
5563        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5564    ) -> Result<VirtioMemEvent, fidl::Error> {
5565        let (bytes, _handles) = buf.split_mut();
5566        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5567        debug_assert_eq!(tx_header.tx_id, 0);
5568        match tx_header.ordinal {
5569            0x73b86d7cc80020b9 => {
5570                let mut out = fidl::new_empty!(
5571                    VirtioMemOnConfigChangedRequest,
5572                    fidl::encoding::DefaultFuchsiaResourceDialect
5573                );
5574                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMemOnConfigChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5575                Ok((VirtioMemEvent::OnConfigChanged { plugged_size: out.plugged_size }))
5576            }
5577            _ => Err(fidl::Error::UnknownOrdinal {
5578                ordinal: tx_header.ordinal,
5579                protocol_name: <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5580            }),
5581        }
5582    }
5583}
5584
5585/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioMem.
5586pub struct VirtioMemRequestStream {
5587    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5588    is_terminated: bool,
5589}
5590
5591impl std::marker::Unpin for VirtioMemRequestStream {}
5592
5593impl futures::stream::FusedStream for VirtioMemRequestStream {
5594    fn is_terminated(&self) -> bool {
5595        self.is_terminated
5596    }
5597}
5598
5599impl fidl::endpoints::RequestStream for VirtioMemRequestStream {
5600    type Protocol = VirtioMemMarker;
5601    type ControlHandle = VirtioMemControlHandle;
5602
5603    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5604        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5605    }
5606
5607    fn control_handle(&self) -> Self::ControlHandle {
5608        VirtioMemControlHandle { inner: self.inner.clone() }
5609    }
5610
5611    fn into_inner(
5612        self,
5613    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5614    {
5615        (self.inner, self.is_terminated)
5616    }
5617
5618    fn from_inner(
5619        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5620        is_terminated: bool,
5621    ) -> Self {
5622        Self { inner, is_terminated }
5623    }
5624}
5625
5626impl futures::Stream for VirtioMemRequestStream {
5627    type Item = Result<VirtioMemRequest, fidl::Error>;
5628
5629    fn poll_next(
5630        mut self: std::pin::Pin<&mut Self>,
5631        cx: &mut std::task::Context<'_>,
5632    ) -> std::task::Poll<Option<Self::Item>> {
5633        let this = &mut *self;
5634        if this.inner.check_shutdown(cx) {
5635            this.is_terminated = true;
5636            return std::task::Poll::Ready(None);
5637        }
5638        if this.is_terminated {
5639            panic!("polled VirtioMemRequestStream after completion");
5640        }
5641        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5642            |bytes, handles| {
5643                match this.inner.channel().read_etc(cx, bytes, handles) {
5644                    std::task::Poll::Ready(Ok(())) => {}
5645                    std::task::Poll::Pending => return std::task::Poll::Pending,
5646                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5647                        this.is_terminated = true;
5648                        return std::task::Poll::Ready(None);
5649                    }
5650                    std::task::Poll::Ready(Err(e)) => {
5651                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5652                            e.into(),
5653                        ))));
5654                    }
5655                }
5656
5657                // A message has been received from the channel
5658                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5659
5660                std::task::Poll::Ready(Some(match header.ordinal {
5661                    0x72b44fb963480b11 => {
5662                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5663                        let mut req = fidl::new_empty!(
5664                            VirtioDeviceConfigureQueueRequest,
5665                            fidl::encoding::DefaultFuchsiaResourceDialect
5666                        );
5667                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
5668                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
5669                        Ok(VirtioMemRequest::ConfigureQueue {
5670                            queue: req.queue,
5671                            size: req.size,
5672                            desc: req.desc,
5673                            avail: req.avail,
5674                            used: req.used,
5675
5676                            responder: VirtioMemConfigureQueueResponder {
5677                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5678                                tx_id: header.tx_id,
5679                            },
5680                        })
5681                    }
5682                    0x6e3a61d652499244 => {
5683                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5684                        let mut req = fidl::new_empty!(
5685                            VirtioDeviceNotifyQueueRequest,
5686                            fidl::encoding::DefaultFuchsiaResourceDialect
5687                        );
5688                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
5689                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
5690                        Ok(VirtioMemRequest::NotifyQueue { queue: req.queue, control_handle })
5691                    }
5692                    0x45707654f5d23c3f => {
5693                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5694                        let mut req = fidl::new_empty!(
5695                            VirtioDeviceReadyRequest,
5696                            fidl::encoding::DefaultFuchsiaResourceDialect
5697                        );
5698                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
5699                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
5700                        Ok(VirtioMemRequest::Ready {
5701                            negotiated_features: req.negotiated_features,
5702
5703                            responder: VirtioMemReadyResponder {
5704                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5705                                tx_id: header.tx_id,
5706                            },
5707                        })
5708                    }
5709                    0x66dd64f17fb5223c => {
5710                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5711                        let mut req = fidl::new_empty!(
5712                            VirtioMemStartRequest,
5713                            fidl::encoding::DefaultFuchsiaResourceDialect
5714                        );
5715                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMemStartRequest>(&header, _body_bytes, handles, &mut req)?;
5716                        let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
5717                        Ok(VirtioMemRequest::Start {
5718                            start_info: req.start_info,
5719                            region_addr: req.region_addr,
5720                            plugged_block_size: req.plugged_block_size,
5721                            region_size: req.region_size,
5722
5723                            responder: VirtioMemStartResponder {
5724                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5725                                tx_id: header.tx_id,
5726                            },
5727                        })
5728                    }
5729                    _ => Err(fidl::Error::UnknownOrdinal {
5730                        ordinal: header.ordinal,
5731                        protocol_name:
5732                            <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5733                    }),
5734                }))
5735            },
5736        )
5737    }
5738}
5739
5740#[derive(Debug)]
5741pub enum VirtioMemRequest {
5742    /// Configure a `queue` for the device. This specifies the `size` and the
5743    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
5744    ConfigureQueue {
5745        queue: u16,
5746        size: u16,
5747        desc: u64,
5748        avail: u64,
5749        used: u64,
5750        responder: VirtioMemConfigureQueueResponder,
5751    },
5752    /// Notify a `queue` for the device. Primarily used for black-box testing.
5753    NotifyQueue { queue: u16, control_handle: VirtioMemControlHandle },
5754    /// Ready a device. This provides the set of `negotiated_features` that the
5755    /// driver and device have agreed upon.
5756    Ready { negotiated_features: u32, responder: VirtioMemReadyResponder },
5757    /// Start the mem device.
5758    Start {
5759        start_info: StartInfo,
5760        region_addr: u64,
5761        plugged_block_size: u64,
5762        region_size: u64,
5763        responder: VirtioMemStartResponder,
5764    },
5765}
5766
5767impl VirtioMemRequest {
5768    #[allow(irrefutable_let_patterns)]
5769    pub fn into_configure_queue(
5770        self,
5771    ) -> Option<(u16, u16, u64, u64, u64, VirtioMemConfigureQueueResponder)> {
5772        if let VirtioMemRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
5773        {
5774            Some((queue, size, desc, avail, used, responder))
5775        } else {
5776            None
5777        }
5778    }
5779
5780    #[allow(irrefutable_let_patterns)]
5781    pub fn into_notify_queue(self) -> Option<(u16, VirtioMemControlHandle)> {
5782        if let VirtioMemRequest::NotifyQueue { queue, control_handle } = self {
5783            Some((queue, control_handle))
5784        } else {
5785            None
5786        }
5787    }
5788
5789    #[allow(irrefutable_let_patterns)]
5790    pub fn into_ready(self) -> Option<(u32, VirtioMemReadyResponder)> {
5791        if let VirtioMemRequest::Ready { negotiated_features, responder } = self {
5792            Some((negotiated_features, responder))
5793        } else {
5794            None
5795        }
5796    }
5797
5798    #[allow(irrefutable_let_patterns)]
5799    pub fn into_start(self) -> Option<(StartInfo, u64, u64, u64, VirtioMemStartResponder)> {
5800        if let VirtioMemRequest::Start {
5801            start_info,
5802            region_addr,
5803            plugged_block_size,
5804            region_size,
5805            responder,
5806        } = self
5807        {
5808            Some((start_info, region_addr, plugged_block_size, region_size, responder))
5809        } else {
5810            None
5811        }
5812    }
5813
5814    /// Name of the method defined in FIDL
5815    pub fn method_name(&self) -> &'static str {
5816        match *self {
5817            VirtioMemRequest::ConfigureQueue { .. } => "configure_queue",
5818            VirtioMemRequest::NotifyQueue { .. } => "notify_queue",
5819            VirtioMemRequest::Ready { .. } => "ready",
5820            VirtioMemRequest::Start { .. } => "start",
5821        }
5822    }
5823}
5824
5825#[derive(Debug, Clone)]
5826pub struct VirtioMemControlHandle {
5827    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5828}
5829
5830impl fidl::endpoints::ControlHandle for VirtioMemControlHandle {
5831    fn shutdown(&self) {
5832        self.inner.shutdown()
5833    }
5834
5835    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5836        self.inner.shutdown_with_epitaph(status)
5837    }
5838
5839    fn is_closed(&self) -> bool {
5840        self.inner.channel().is_closed()
5841    }
5842    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5843        self.inner.channel().on_closed()
5844    }
5845
5846    #[cfg(target_os = "fuchsia")]
5847    fn signal_peer(
5848        &self,
5849        clear_mask: zx::Signals,
5850        set_mask: zx::Signals,
5851    ) -> Result<(), zx_status::Status> {
5852        use fidl::Peered;
5853        self.inner.channel().signal_peer(clear_mask, set_mask)
5854    }
5855}
5856
5857impl VirtioMemControlHandle {
5858    pub fn send_on_config_changed(&self, mut plugged_size: u64) -> Result<(), fidl::Error> {
5859        self.inner.send::<VirtioMemOnConfigChangedRequest>(
5860            (plugged_size,),
5861            0,
5862            0x73b86d7cc80020b9,
5863            fidl::encoding::DynamicFlags::empty(),
5864        )
5865    }
5866}
5867
5868#[must_use = "FIDL methods require a response to be sent"]
5869#[derive(Debug)]
5870pub struct VirtioMemConfigureQueueResponder {
5871    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
5872    tx_id: u32,
5873}
5874
5875/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
5876/// if the responder is dropped without sending a response, so that the client
5877/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5878impl std::ops::Drop for VirtioMemConfigureQueueResponder {
5879    fn drop(&mut self) {
5880        self.control_handle.shutdown();
5881        // Safety: drops once, never accessed again
5882        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5883    }
5884}
5885
5886impl fidl::endpoints::Responder for VirtioMemConfigureQueueResponder {
5887    type ControlHandle = VirtioMemControlHandle;
5888
5889    fn control_handle(&self) -> &VirtioMemControlHandle {
5890        &self.control_handle
5891    }
5892
5893    fn drop_without_shutdown(mut self) {
5894        // Safety: drops once, never accessed again due to mem::forget
5895        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5896        // Prevent Drop from running (which would shut down the channel)
5897        std::mem::forget(self);
5898    }
5899}
5900
5901impl VirtioMemConfigureQueueResponder {
5902    /// Sends a response to the FIDL transaction.
5903    ///
5904    /// Sets the channel to shutdown if an error occurs.
5905    pub fn send(self) -> Result<(), fidl::Error> {
5906        let _result = self.send_raw();
5907        if _result.is_err() {
5908            self.control_handle.shutdown();
5909        }
5910        self.drop_without_shutdown();
5911        _result
5912    }
5913
5914    /// Similar to "send" but does not shutdown the channel if an error occurs.
5915    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5916        let _result = self.send_raw();
5917        self.drop_without_shutdown();
5918        _result
5919    }
5920
5921    fn send_raw(&self) -> Result<(), fidl::Error> {
5922        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5923            (),
5924            self.tx_id,
5925            0x72b44fb963480b11,
5926            fidl::encoding::DynamicFlags::empty(),
5927        )
5928    }
5929}
5930
5931#[must_use = "FIDL methods require a response to be sent"]
5932#[derive(Debug)]
5933pub struct VirtioMemReadyResponder {
5934    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
5935    tx_id: u32,
5936}
5937
5938/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
5939/// if the responder is dropped without sending a response, so that the client
5940/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5941impl std::ops::Drop for VirtioMemReadyResponder {
5942    fn drop(&mut self) {
5943        self.control_handle.shutdown();
5944        // Safety: drops once, never accessed again
5945        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5946    }
5947}
5948
5949impl fidl::endpoints::Responder for VirtioMemReadyResponder {
5950    type ControlHandle = VirtioMemControlHandle;
5951
5952    fn control_handle(&self) -> &VirtioMemControlHandle {
5953        &self.control_handle
5954    }
5955
5956    fn drop_without_shutdown(mut self) {
5957        // Safety: drops once, never accessed again due to mem::forget
5958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5959        // Prevent Drop from running (which would shut down the channel)
5960        std::mem::forget(self);
5961    }
5962}
5963
5964impl VirtioMemReadyResponder {
5965    /// Sends a response to the FIDL transaction.
5966    ///
5967    /// Sets the channel to shutdown if an error occurs.
5968    pub fn send(self) -> Result<(), fidl::Error> {
5969        let _result = self.send_raw();
5970        if _result.is_err() {
5971            self.control_handle.shutdown();
5972        }
5973        self.drop_without_shutdown();
5974        _result
5975    }
5976
5977    /// Similar to "send" but does not shutdown the channel if an error occurs.
5978    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5979        let _result = self.send_raw();
5980        self.drop_without_shutdown();
5981        _result
5982    }
5983
5984    fn send_raw(&self) -> Result<(), fidl::Error> {
5985        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
5986            (),
5987            self.tx_id,
5988            0x45707654f5d23c3f,
5989            fidl::encoding::DynamicFlags::empty(),
5990        )
5991    }
5992}
5993
5994#[must_use = "FIDL methods require a response to be sent"]
5995#[derive(Debug)]
5996pub struct VirtioMemStartResponder {
5997    control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
5998    tx_id: u32,
5999}
6000
6001/// Set the the channel to be shutdown (see [`VirtioMemControlHandle::shutdown`])
6002/// if the responder is dropped without sending a response, so that the client
6003/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6004impl std::ops::Drop for VirtioMemStartResponder {
6005    fn drop(&mut self) {
6006        self.control_handle.shutdown();
6007        // Safety: drops once, never accessed again
6008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6009    }
6010}
6011
6012impl fidl::endpoints::Responder for VirtioMemStartResponder {
6013    type ControlHandle = VirtioMemControlHandle;
6014
6015    fn control_handle(&self) -> &VirtioMemControlHandle {
6016        &self.control_handle
6017    }
6018
6019    fn drop_without_shutdown(mut self) {
6020        // Safety: drops once, never accessed again due to mem::forget
6021        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6022        // Prevent Drop from running (which would shut down the channel)
6023        std::mem::forget(self);
6024    }
6025}
6026
6027impl VirtioMemStartResponder {
6028    /// Sends a response to the FIDL transaction.
6029    ///
6030    /// Sets the channel to shutdown if an error occurs.
6031    pub fn send(self) -> Result<(), fidl::Error> {
6032        let _result = self.send_raw();
6033        if _result.is_err() {
6034            self.control_handle.shutdown();
6035        }
6036        self.drop_without_shutdown();
6037        _result
6038    }
6039
6040    /// Similar to "send" but does not shutdown the channel if an error occurs.
6041    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6042        let _result = self.send_raw();
6043        self.drop_without_shutdown();
6044        _result
6045    }
6046
6047    fn send_raw(&self) -> Result<(), fidl::Error> {
6048        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6049            (),
6050            self.tx_id,
6051            0x66dd64f17fb5223c,
6052            fidl::encoding::DynamicFlags::empty(),
6053        )
6054    }
6055}
6056
6057#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6058pub struct VirtioNetMarker;
6059
6060impl fidl::endpoints::ProtocolMarker for VirtioNetMarker {
6061    type Proxy = VirtioNetProxy;
6062    type RequestStream = VirtioNetRequestStream;
6063    #[cfg(target_os = "fuchsia")]
6064    type SynchronousProxy = VirtioNetSynchronousProxy;
6065
6066    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioNet";
6067}
6068impl fidl::endpoints::DiscoverableProtocolMarker for VirtioNetMarker {}
6069pub type VirtioNetStartResult = Result<(), i32>;
6070
6071pub trait VirtioNetProxyInterface: Send + Sync {
6072    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6073    fn r#configure_queue(
6074        &self,
6075        queue: u16,
6076        size: u16,
6077        desc: u64,
6078        avail: u64,
6079        used: u64,
6080    ) -> Self::ConfigureQueueResponseFut;
6081    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
6082    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6083    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
6084    type StartResponseFut: std::future::Future<Output = Result<VirtioNetStartResult, fidl::Error>>
6085        + Send;
6086    fn r#start(
6087        &self,
6088        start_info: StartInfo,
6089        mac_address: &fidl_fuchsia_net::MacAddress,
6090        enable_bridge: bool,
6091    ) -> Self::StartResponseFut;
6092}
6093#[derive(Debug)]
6094#[cfg(target_os = "fuchsia")]
6095pub struct VirtioNetSynchronousProxy {
6096    client: fidl::client::sync::Client,
6097}
6098
6099#[cfg(target_os = "fuchsia")]
6100impl fidl::endpoints::SynchronousProxy for VirtioNetSynchronousProxy {
6101    type Proxy = VirtioNetProxy;
6102    type Protocol = VirtioNetMarker;
6103
6104    fn from_channel(inner: fidl::Channel) -> Self {
6105        Self::new(inner)
6106    }
6107
6108    fn into_channel(self) -> fidl::Channel {
6109        self.client.into_channel()
6110    }
6111
6112    fn as_channel(&self) -> &fidl::Channel {
6113        self.client.as_channel()
6114    }
6115}
6116
6117#[cfg(target_os = "fuchsia")]
6118impl VirtioNetSynchronousProxy {
6119    pub fn new(channel: fidl::Channel) -> Self {
6120        Self { client: fidl::client::sync::Client::new(channel) }
6121    }
6122
6123    pub fn into_channel(self) -> fidl::Channel {
6124        self.client.into_channel()
6125    }
6126
6127    /// Waits until an event arrives and returns it. It is safe for other
6128    /// threads to make concurrent requests while waiting for an event.
6129    pub fn wait_for_event(
6130        &self,
6131        deadline: zx::MonotonicInstant,
6132    ) -> Result<VirtioNetEvent, fidl::Error> {
6133        VirtioNetEvent::decode(self.client.wait_for_event::<VirtioNetMarker>(deadline)?)
6134    }
6135
6136    /// Configure a `queue` for the device. This specifies the `size` and the
6137    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6138    pub fn r#configure_queue(
6139        &self,
6140        mut queue: u16,
6141        mut size: u16,
6142        mut desc: u64,
6143        mut avail: u64,
6144        mut used: u64,
6145        ___deadline: zx::MonotonicInstant,
6146    ) -> Result<(), fidl::Error> {
6147        let _response = self.client.send_query::<
6148            VirtioDeviceConfigureQueueRequest,
6149            fidl::encoding::EmptyPayload,
6150            VirtioNetMarker,
6151        >(
6152            (queue, size, desc, avail, used,),
6153            0x72b44fb963480b11,
6154            fidl::encoding::DynamicFlags::empty(),
6155            ___deadline,
6156        )?;
6157        Ok(_response)
6158    }
6159
6160    /// Notify a `queue` for the device. Primarily used for black-box testing.
6161    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6162        self.client.send::<VirtioDeviceNotifyQueueRequest>(
6163            (queue,),
6164            0x6e3a61d652499244,
6165            fidl::encoding::DynamicFlags::empty(),
6166        )
6167    }
6168
6169    /// Ready a device. This provides the set of `negotiated_features` that the
6170    /// driver and device have agreed upon.
6171    pub fn r#ready(
6172        &self,
6173        mut negotiated_features: u32,
6174        ___deadline: zx::MonotonicInstant,
6175    ) -> Result<(), fidl::Error> {
6176        let _response = self
6177            .client
6178            .send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload, VirtioNetMarker>(
6179                (negotiated_features,),
6180                0x45707654f5d23c3f,
6181                fidl::encoding::DynamicFlags::empty(),
6182                ___deadline,
6183            )?;
6184        Ok(_response)
6185    }
6186
6187    /// Start the net device.
6188    pub fn r#start(
6189        &self,
6190        mut start_info: StartInfo,
6191        mut mac_address: &fidl_fuchsia_net::MacAddress,
6192        mut enable_bridge: bool,
6193        ___deadline: zx::MonotonicInstant,
6194    ) -> Result<VirtioNetStartResult, fidl::Error> {
6195        let _response = self.client.send_query::<
6196            VirtioNetStartRequest,
6197            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6198            VirtioNetMarker,
6199        >(
6200            (&mut start_info, mac_address, enable_bridge,),
6201            0x795c0b3a8461b3ed,
6202            fidl::encoding::DynamicFlags::empty(),
6203            ___deadline,
6204        )?;
6205        Ok(_response.map(|x| x))
6206    }
6207}
6208
6209#[cfg(target_os = "fuchsia")]
6210impl From<VirtioNetSynchronousProxy> for zx::NullableHandle {
6211    fn from(value: VirtioNetSynchronousProxy) -> Self {
6212        value.into_channel().into()
6213    }
6214}
6215
6216#[cfg(target_os = "fuchsia")]
6217impl From<fidl::Channel> for VirtioNetSynchronousProxy {
6218    fn from(value: fidl::Channel) -> Self {
6219        Self::new(value)
6220    }
6221}
6222
6223#[cfg(target_os = "fuchsia")]
6224impl fidl::endpoints::FromClient for VirtioNetSynchronousProxy {
6225    type Protocol = VirtioNetMarker;
6226
6227    fn from_client(value: fidl::endpoints::ClientEnd<VirtioNetMarker>) -> Self {
6228        Self::new(value.into_channel())
6229    }
6230}
6231
6232#[derive(Debug, Clone)]
6233pub struct VirtioNetProxy {
6234    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6235}
6236
6237impl fidl::endpoints::Proxy for VirtioNetProxy {
6238    type Protocol = VirtioNetMarker;
6239
6240    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6241        Self::new(inner)
6242    }
6243
6244    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6245        self.client.into_channel().map_err(|client| Self { client })
6246    }
6247
6248    fn as_channel(&self) -> &::fidl::AsyncChannel {
6249        self.client.as_channel()
6250    }
6251}
6252
6253impl VirtioNetProxy {
6254    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioNet.
6255    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6256        let protocol_name = <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6257        Self { client: fidl::client::Client::new(channel, protocol_name) }
6258    }
6259
6260    /// Get a Stream of events from the remote end of the protocol.
6261    ///
6262    /// # Panics
6263    ///
6264    /// Panics if the event stream was already taken.
6265    pub fn take_event_stream(&self) -> VirtioNetEventStream {
6266        VirtioNetEventStream { event_receiver: self.client.take_event_receiver() }
6267    }
6268
6269    /// Configure a `queue` for the device. This specifies the `size` and the
6270    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6271    pub fn r#configure_queue(
6272        &self,
6273        mut queue: u16,
6274        mut size: u16,
6275        mut desc: u64,
6276        mut avail: u64,
6277        mut used: u64,
6278    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6279        VirtioNetProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
6280    }
6281
6282    /// Notify a `queue` for the device. Primarily used for black-box testing.
6283    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6284        VirtioNetProxyInterface::r#notify_queue(self, queue)
6285    }
6286
6287    /// Ready a device. This provides the set of `negotiated_features` that the
6288    /// driver and device have agreed upon.
6289    pub fn r#ready(
6290        &self,
6291        mut negotiated_features: u32,
6292    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6293        VirtioNetProxyInterface::r#ready(self, negotiated_features)
6294    }
6295
6296    /// Start the net device.
6297    pub fn r#start(
6298        &self,
6299        mut start_info: StartInfo,
6300        mut mac_address: &fidl_fuchsia_net::MacAddress,
6301        mut enable_bridge: bool,
6302    ) -> fidl::client::QueryResponseFut<
6303        VirtioNetStartResult,
6304        fidl::encoding::DefaultFuchsiaResourceDialect,
6305    > {
6306        VirtioNetProxyInterface::r#start(self, start_info, mac_address, enable_bridge)
6307    }
6308}
6309
6310impl VirtioNetProxyInterface for VirtioNetProxy {
6311    type ConfigureQueueResponseFut =
6312        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6313    fn r#configure_queue(
6314        &self,
6315        mut queue: u16,
6316        mut size: u16,
6317        mut desc: u64,
6318        mut avail: u64,
6319        mut used: u64,
6320    ) -> Self::ConfigureQueueResponseFut {
6321        fn _decode(
6322            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6323        ) -> Result<(), fidl::Error> {
6324            let _response = fidl::client::decode_transaction_body::<
6325                fidl::encoding::EmptyPayload,
6326                fidl::encoding::DefaultFuchsiaResourceDialect,
6327                0x72b44fb963480b11,
6328            >(_buf?)?;
6329            Ok(_response)
6330        }
6331        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
6332            (queue, size, desc, avail, used),
6333            0x72b44fb963480b11,
6334            fidl::encoding::DynamicFlags::empty(),
6335            _decode,
6336        )
6337    }
6338
6339    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
6340        self.client.send::<VirtioDeviceNotifyQueueRequest>(
6341            (queue,),
6342            0x6e3a61d652499244,
6343            fidl::encoding::DynamicFlags::empty(),
6344        )
6345    }
6346
6347    type ReadyResponseFut =
6348        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6349    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
6350        fn _decode(
6351            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6352        ) -> Result<(), fidl::Error> {
6353            let _response = fidl::client::decode_transaction_body::<
6354                fidl::encoding::EmptyPayload,
6355                fidl::encoding::DefaultFuchsiaResourceDialect,
6356                0x45707654f5d23c3f,
6357            >(_buf?)?;
6358            Ok(_response)
6359        }
6360        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
6361            (negotiated_features,),
6362            0x45707654f5d23c3f,
6363            fidl::encoding::DynamicFlags::empty(),
6364            _decode,
6365        )
6366    }
6367
6368    type StartResponseFut = fidl::client::QueryResponseFut<
6369        VirtioNetStartResult,
6370        fidl::encoding::DefaultFuchsiaResourceDialect,
6371    >;
6372    fn r#start(
6373        &self,
6374        mut start_info: StartInfo,
6375        mut mac_address: &fidl_fuchsia_net::MacAddress,
6376        mut enable_bridge: bool,
6377    ) -> Self::StartResponseFut {
6378        fn _decode(
6379            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6380        ) -> Result<VirtioNetStartResult, fidl::Error> {
6381            let _response = fidl::client::decode_transaction_body::<
6382                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6383                fidl::encoding::DefaultFuchsiaResourceDialect,
6384                0x795c0b3a8461b3ed,
6385            >(_buf?)?;
6386            Ok(_response.map(|x| x))
6387        }
6388        self.client.send_query_and_decode::<VirtioNetStartRequest, VirtioNetStartResult>(
6389            (&mut start_info, mac_address, enable_bridge),
6390            0x795c0b3a8461b3ed,
6391            fidl::encoding::DynamicFlags::empty(),
6392            _decode,
6393        )
6394    }
6395}
6396
6397pub struct VirtioNetEventStream {
6398    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6399}
6400
6401impl std::marker::Unpin for VirtioNetEventStream {}
6402
6403impl futures::stream::FusedStream for VirtioNetEventStream {
6404    fn is_terminated(&self) -> bool {
6405        self.event_receiver.is_terminated()
6406    }
6407}
6408
6409impl futures::Stream for VirtioNetEventStream {
6410    type Item = Result<VirtioNetEvent, fidl::Error>;
6411
6412    fn poll_next(
6413        mut self: std::pin::Pin<&mut Self>,
6414        cx: &mut std::task::Context<'_>,
6415    ) -> std::task::Poll<Option<Self::Item>> {
6416        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6417            &mut self.event_receiver,
6418            cx
6419        )?) {
6420            Some(buf) => std::task::Poll::Ready(Some(VirtioNetEvent::decode(buf))),
6421            None => std::task::Poll::Ready(None),
6422        }
6423    }
6424}
6425
6426#[derive(Debug)]
6427pub enum VirtioNetEvent {}
6428
6429impl VirtioNetEvent {
6430    /// Decodes a message buffer as a [`VirtioNetEvent`].
6431    fn decode(
6432        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6433    ) -> Result<VirtioNetEvent, fidl::Error> {
6434        let (bytes, _handles) = buf.split_mut();
6435        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6436        debug_assert_eq!(tx_header.tx_id, 0);
6437        match tx_header.ordinal {
6438            _ => Err(fidl::Error::UnknownOrdinal {
6439                ordinal: tx_header.ordinal,
6440                protocol_name: <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6441            }),
6442        }
6443    }
6444}
6445
6446/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioNet.
6447pub struct VirtioNetRequestStream {
6448    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6449    is_terminated: bool,
6450}
6451
6452impl std::marker::Unpin for VirtioNetRequestStream {}
6453
6454impl futures::stream::FusedStream for VirtioNetRequestStream {
6455    fn is_terminated(&self) -> bool {
6456        self.is_terminated
6457    }
6458}
6459
6460impl fidl::endpoints::RequestStream for VirtioNetRequestStream {
6461    type Protocol = VirtioNetMarker;
6462    type ControlHandle = VirtioNetControlHandle;
6463
6464    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6465        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6466    }
6467
6468    fn control_handle(&self) -> Self::ControlHandle {
6469        VirtioNetControlHandle { inner: self.inner.clone() }
6470    }
6471
6472    fn into_inner(
6473        self,
6474    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6475    {
6476        (self.inner, self.is_terminated)
6477    }
6478
6479    fn from_inner(
6480        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6481        is_terminated: bool,
6482    ) -> Self {
6483        Self { inner, is_terminated }
6484    }
6485}
6486
6487impl futures::Stream for VirtioNetRequestStream {
6488    type Item = Result<VirtioNetRequest, fidl::Error>;
6489
6490    fn poll_next(
6491        mut self: std::pin::Pin<&mut Self>,
6492        cx: &mut std::task::Context<'_>,
6493    ) -> std::task::Poll<Option<Self::Item>> {
6494        let this = &mut *self;
6495        if this.inner.check_shutdown(cx) {
6496            this.is_terminated = true;
6497            return std::task::Poll::Ready(None);
6498        }
6499        if this.is_terminated {
6500            panic!("polled VirtioNetRequestStream after completion");
6501        }
6502        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6503            |bytes, handles| {
6504                match this.inner.channel().read_etc(cx, bytes, handles) {
6505                    std::task::Poll::Ready(Ok(())) => {}
6506                    std::task::Poll::Pending => return std::task::Poll::Pending,
6507                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6508                        this.is_terminated = true;
6509                        return std::task::Poll::Ready(None);
6510                    }
6511                    std::task::Poll::Ready(Err(e)) => {
6512                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6513                            e.into(),
6514                        ))));
6515                    }
6516                }
6517
6518                // A message has been received from the channel
6519                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6520
6521                std::task::Poll::Ready(Some(match header.ordinal {
6522                    0x72b44fb963480b11 => {
6523                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6524                        let mut req = fidl::new_empty!(
6525                            VirtioDeviceConfigureQueueRequest,
6526                            fidl::encoding::DefaultFuchsiaResourceDialect
6527                        );
6528                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
6529                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
6530                        Ok(VirtioNetRequest::ConfigureQueue {
6531                            queue: req.queue,
6532                            size: req.size,
6533                            desc: req.desc,
6534                            avail: req.avail,
6535                            used: req.used,
6536
6537                            responder: VirtioNetConfigureQueueResponder {
6538                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6539                                tx_id: header.tx_id,
6540                            },
6541                        })
6542                    }
6543                    0x6e3a61d652499244 => {
6544                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6545                        let mut req = fidl::new_empty!(
6546                            VirtioDeviceNotifyQueueRequest,
6547                            fidl::encoding::DefaultFuchsiaResourceDialect
6548                        );
6549                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
6550                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
6551                        Ok(VirtioNetRequest::NotifyQueue { queue: req.queue, control_handle })
6552                    }
6553                    0x45707654f5d23c3f => {
6554                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6555                        let mut req = fidl::new_empty!(
6556                            VirtioDeviceReadyRequest,
6557                            fidl::encoding::DefaultFuchsiaResourceDialect
6558                        );
6559                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
6560                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
6561                        Ok(VirtioNetRequest::Ready {
6562                            negotiated_features: req.negotiated_features,
6563
6564                            responder: VirtioNetReadyResponder {
6565                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6566                                tx_id: header.tx_id,
6567                            },
6568                        })
6569                    }
6570                    0x795c0b3a8461b3ed => {
6571                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6572                        let mut req = fidl::new_empty!(
6573                            VirtioNetStartRequest,
6574                            fidl::encoding::DefaultFuchsiaResourceDialect
6575                        );
6576                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioNetStartRequest>(&header, _body_bytes, handles, &mut req)?;
6577                        let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
6578                        Ok(VirtioNetRequest::Start {
6579                            start_info: req.start_info,
6580                            mac_address: req.mac_address,
6581                            enable_bridge: req.enable_bridge,
6582
6583                            responder: VirtioNetStartResponder {
6584                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6585                                tx_id: header.tx_id,
6586                            },
6587                        })
6588                    }
6589                    _ => Err(fidl::Error::UnknownOrdinal {
6590                        ordinal: header.ordinal,
6591                        protocol_name:
6592                            <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6593                    }),
6594                }))
6595            },
6596        )
6597    }
6598}
6599
6600#[derive(Debug)]
6601pub enum VirtioNetRequest {
6602    /// Configure a `queue` for the device. This specifies the `size` and the
6603    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6604    ConfigureQueue {
6605        queue: u16,
6606        size: u16,
6607        desc: u64,
6608        avail: u64,
6609        used: u64,
6610        responder: VirtioNetConfigureQueueResponder,
6611    },
6612    /// Notify a `queue` for the device. Primarily used for black-box testing.
6613    NotifyQueue { queue: u16, control_handle: VirtioNetControlHandle },
6614    /// Ready a device. This provides the set of `negotiated_features` that the
6615    /// driver and device have agreed upon.
6616    Ready { negotiated_features: u32, responder: VirtioNetReadyResponder },
6617    /// Start the net device.
6618    Start {
6619        start_info: StartInfo,
6620        mac_address: fidl_fuchsia_net::MacAddress,
6621        enable_bridge: bool,
6622        responder: VirtioNetStartResponder,
6623    },
6624}
6625
6626impl VirtioNetRequest {
6627    #[allow(irrefutable_let_patterns)]
6628    pub fn into_configure_queue(
6629        self,
6630    ) -> Option<(u16, u16, u64, u64, u64, VirtioNetConfigureQueueResponder)> {
6631        if let VirtioNetRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
6632        {
6633            Some((queue, size, desc, avail, used, responder))
6634        } else {
6635            None
6636        }
6637    }
6638
6639    #[allow(irrefutable_let_patterns)]
6640    pub fn into_notify_queue(self) -> Option<(u16, VirtioNetControlHandle)> {
6641        if let VirtioNetRequest::NotifyQueue { queue, control_handle } = self {
6642            Some((queue, control_handle))
6643        } else {
6644            None
6645        }
6646    }
6647
6648    #[allow(irrefutable_let_patterns)]
6649    pub fn into_ready(self) -> Option<(u32, VirtioNetReadyResponder)> {
6650        if let VirtioNetRequest::Ready { negotiated_features, responder } = self {
6651            Some((negotiated_features, responder))
6652        } else {
6653            None
6654        }
6655    }
6656
6657    #[allow(irrefutable_let_patterns)]
6658    pub fn into_start(
6659        self,
6660    ) -> Option<(StartInfo, fidl_fuchsia_net::MacAddress, bool, VirtioNetStartResponder)> {
6661        if let VirtioNetRequest::Start { start_info, mac_address, enable_bridge, responder } = self
6662        {
6663            Some((start_info, mac_address, enable_bridge, responder))
6664        } else {
6665            None
6666        }
6667    }
6668
6669    /// Name of the method defined in FIDL
6670    pub fn method_name(&self) -> &'static str {
6671        match *self {
6672            VirtioNetRequest::ConfigureQueue { .. } => "configure_queue",
6673            VirtioNetRequest::NotifyQueue { .. } => "notify_queue",
6674            VirtioNetRequest::Ready { .. } => "ready",
6675            VirtioNetRequest::Start { .. } => "start",
6676        }
6677    }
6678}
6679
6680#[derive(Debug, Clone)]
6681pub struct VirtioNetControlHandle {
6682    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6683}
6684
6685impl fidl::endpoints::ControlHandle for VirtioNetControlHandle {
6686    fn shutdown(&self) {
6687        self.inner.shutdown()
6688    }
6689
6690    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6691        self.inner.shutdown_with_epitaph(status)
6692    }
6693
6694    fn is_closed(&self) -> bool {
6695        self.inner.channel().is_closed()
6696    }
6697    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6698        self.inner.channel().on_closed()
6699    }
6700
6701    #[cfg(target_os = "fuchsia")]
6702    fn signal_peer(
6703        &self,
6704        clear_mask: zx::Signals,
6705        set_mask: zx::Signals,
6706    ) -> Result<(), zx_status::Status> {
6707        use fidl::Peered;
6708        self.inner.channel().signal_peer(clear_mask, set_mask)
6709    }
6710}
6711
6712impl VirtioNetControlHandle {}
6713
6714#[must_use = "FIDL methods require a response to be sent"]
6715#[derive(Debug)]
6716pub struct VirtioNetConfigureQueueResponder {
6717    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
6718    tx_id: u32,
6719}
6720
6721/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
6722/// if the responder is dropped without sending a response, so that the client
6723/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6724impl std::ops::Drop for VirtioNetConfigureQueueResponder {
6725    fn drop(&mut self) {
6726        self.control_handle.shutdown();
6727        // Safety: drops once, never accessed again
6728        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6729    }
6730}
6731
6732impl fidl::endpoints::Responder for VirtioNetConfigureQueueResponder {
6733    type ControlHandle = VirtioNetControlHandle;
6734
6735    fn control_handle(&self) -> &VirtioNetControlHandle {
6736        &self.control_handle
6737    }
6738
6739    fn drop_without_shutdown(mut self) {
6740        // Safety: drops once, never accessed again due to mem::forget
6741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6742        // Prevent Drop from running (which would shut down the channel)
6743        std::mem::forget(self);
6744    }
6745}
6746
6747impl VirtioNetConfigureQueueResponder {
6748    /// Sends a response to the FIDL transaction.
6749    ///
6750    /// Sets the channel to shutdown if an error occurs.
6751    pub fn send(self) -> Result<(), fidl::Error> {
6752        let _result = self.send_raw();
6753        if _result.is_err() {
6754            self.control_handle.shutdown();
6755        }
6756        self.drop_without_shutdown();
6757        _result
6758    }
6759
6760    /// Similar to "send" but does not shutdown the channel if an error occurs.
6761    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6762        let _result = self.send_raw();
6763        self.drop_without_shutdown();
6764        _result
6765    }
6766
6767    fn send_raw(&self) -> Result<(), fidl::Error> {
6768        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6769            (),
6770            self.tx_id,
6771            0x72b44fb963480b11,
6772            fidl::encoding::DynamicFlags::empty(),
6773        )
6774    }
6775}
6776
6777#[must_use = "FIDL methods require a response to be sent"]
6778#[derive(Debug)]
6779pub struct VirtioNetReadyResponder {
6780    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
6781    tx_id: u32,
6782}
6783
6784/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
6785/// if the responder is dropped without sending a response, so that the client
6786/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6787impl std::ops::Drop for VirtioNetReadyResponder {
6788    fn drop(&mut self) {
6789        self.control_handle.shutdown();
6790        // Safety: drops once, never accessed again
6791        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6792    }
6793}
6794
6795impl fidl::endpoints::Responder for VirtioNetReadyResponder {
6796    type ControlHandle = VirtioNetControlHandle;
6797
6798    fn control_handle(&self) -> &VirtioNetControlHandle {
6799        &self.control_handle
6800    }
6801
6802    fn drop_without_shutdown(mut self) {
6803        // Safety: drops once, never accessed again due to mem::forget
6804        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6805        // Prevent Drop from running (which would shut down the channel)
6806        std::mem::forget(self);
6807    }
6808}
6809
6810impl VirtioNetReadyResponder {
6811    /// Sends a response to the FIDL transaction.
6812    ///
6813    /// Sets the channel to shutdown if an error occurs.
6814    pub fn send(self) -> Result<(), fidl::Error> {
6815        let _result = self.send_raw();
6816        if _result.is_err() {
6817            self.control_handle.shutdown();
6818        }
6819        self.drop_without_shutdown();
6820        _result
6821    }
6822
6823    /// Similar to "send" but does not shutdown the channel if an error occurs.
6824    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6825        let _result = self.send_raw();
6826        self.drop_without_shutdown();
6827        _result
6828    }
6829
6830    fn send_raw(&self) -> Result<(), fidl::Error> {
6831        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6832            (),
6833            self.tx_id,
6834            0x45707654f5d23c3f,
6835            fidl::encoding::DynamicFlags::empty(),
6836        )
6837    }
6838}
6839
6840#[must_use = "FIDL methods require a response to be sent"]
6841#[derive(Debug)]
6842pub struct VirtioNetStartResponder {
6843    control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
6844    tx_id: u32,
6845}
6846
6847/// Set the the channel to be shutdown (see [`VirtioNetControlHandle::shutdown`])
6848/// if the responder is dropped without sending a response, so that the client
6849/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6850impl std::ops::Drop for VirtioNetStartResponder {
6851    fn drop(&mut self) {
6852        self.control_handle.shutdown();
6853        // Safety: drops once, never accessed again
6854        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6855    }
6856}
6857
6858impl fidl::endpoints::Responder for VirtioNetStartResponder {
6859    type ControlHandle = VirtioNetControlHandle;
6860
6861    fn control_handle(&self) -> &VirtioNetControlHandle {
6862        &self.control_handle
6863    }
6864
6865    fn drop_without_shutdown(mut self) {
6866        // Safety: drops once, never accessed again due to mem::forget
6867        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6868        // Prevent Drop from running (which would shut down the channel)
6869        std::mem::forget(self);
6870    }
6871}
6872
6873impl VirtioNetStartResponder {
6874    /// Sends a response to the FIDL transaction.
6875    ///
6876    /// Sets the channel to shutdown if an error occurs.
6877    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6878        let _result = self.send_raw(result);
6879        if _result.is_err() {
6880            self.control_handle.shutdown();
6881        }
6882        self.drop_without_shutdown();
6883        _result
6884    }
6885
6886    /// Similar to "send" but does not shutdown the channel if an error occurs.
6887    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6888        let _result = self.send_raw(result);
6889        self.drop_without_shutdown();
6890        _result
6891    }
6892
6893    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6894        self.control_handle
6895            .inner
6896            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6897                result,
6898                self.tx_id,
6899                0x795c0b3a8461b3ed,
6900                fidl::encoding::DynamicFlags::empty(),
6901            )
6902    }
6903}
6904
6905#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6906pub struct VirtioRngMarker;
6907
6908impl fidl::endpoints::ProtocolMarker for VirtioRngMarker {
6909    type Proxy = VirtioRngProxy;
6910    type RequestStream = VirtioRngRequestStream;
6911    #[cfg(target_os = "fuchsia")]
6912    type SynchronousProxy = VirtioRngSynchronousProxy;
6913
6914    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioRng";
6915}
6916impl fidl::endpoints::DiscoverableProtocolMarker for VirtioRngMarker {}
6917
6918pub trait VirtioRngProxyInterface: Send + Sync {
6919    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6920    fn r#configure_queue(
6921        &self,
6922        queue: u16,
6923        size: u16,
6924        desc: u64,
6925        avail: u64,
6926        used: u64,
6927    ) -> Self::ConfigureQueueResponseFut;
6928    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
6929    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6930    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
6931    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6932    fn r#start(&self, start_info: StartInfo) -> Self::StartResponseFut;
6933}
6934#[derive(Debug)]
6935#[cfg(target_os = "fuchsia")]
6936pub struct VirtioRngSynchronousProxy {
6937    client: fidl::client::sync::Client,
6938}
6939
6940#[cfg(target_os = "fuchsia")]
6941impl fidl::endpoints::SynchronousProxy for VirtioRngSynchronousProxy {
6942    type Proxy = VirtioRngProxy;
6943    type Protocol = VirtioRngMarker;
6944
6945    fn from_channel(inner: fidl::Channel) -> Self {
6946        Self::new(inner)
6947    }
6948
6949    fn into_channel(self) -> fidl::Channel {
6950        self.client.into_channel()
6951    }
6952
6953    fn as_channel(&self) -> &fidl::Channel {
6954        self.client.as_channel()
6955    }
6956}
6957
6958#[cfg(target_os = "fuchsia")]
6959impl VirtioRngSynchronousProxy {
6960    pub fn new(channel: fidl::Channel) -> Self {
6961        Self { client: fidl::client::sync::Client::new(channel) }
6962    }
6963
6964    pub fn into_channel(self) -> fidl::Channel {
6965        self.client.into_channel()
6966    }
6967
6968    /// Waits until an event arrives and returns it. It is safe for other
6969    /// threads to make concurrent requests while waiting for an event.
6970    pub fn wait_for_event(
6971        &self,
6972        deadline: zx::MonotonicInstant,
6973    ) -> Result<VirtioRngEvent, fidl::Error> {
6974        VirtioRngEvent::decode(self.client.wait_for_event::<VirtioRngMarker>(deadline)?)
6975    }
6976
6977    /// Configure a `queue` for the device. This specifies the `size` and the
6978    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
6979    pub fn r#configure_queue(
6980        &self,
6981        mut queue: u16,
6982        mut size: u16,
6983        mut desc: u64,
6984        mut avail: u64,
6985        mut used: u64,
6986        ___deadline: zx::MonotonicInstant,
6987    ) -> Result<(), fidl::Error> {
6988        let _response = self.client.send_query::<
6989            VirtioDeviceConfigureQueueRequest,
6990            fidl::encoding::EmptyPayload,
6991            VirtioRngMarker,
6992        >(
6993            (queue, size, desc, avail, used,),
6994            0x72b44fb963480b11,
6995            fidl::encoding::DynamicFlags::empty(),
6996            ___deadline,
6997        )?;
6998        Ok(_response)
6999    }
7000
7001    /// Notify a `queue` for the device. Primarily used for black-box testing.
7002    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7003        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7004            (queue,),
7005            0x6e3a61d652499244,
7006            fidl::encoding::DynamicFlags::empty(),
7007        )
7008    }
7009
7010    /// Ready a device. This provides the set of `negotiated_features` that the
7011    /// driver and device have agreed upon.
7012    pub fn r#ready(
7013        &self,
7014        mut negotiated_features: u32,
7015        ___deadline: zx::MonotonicInstant,
7016    ) -> Result<(), fidl::Error> {
7017        let _response = self
7018            .client
7019            .send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload, VirtioRngMarker>(
7020                (negotiated_features,),
7021                0x45707654f5d23c3f,
7022                fidl::encoding::DynamicFlags::empty(),
7023                ___deadline,
7024            )?;
7025        Ok(_response)
7026    }
7027
7028    /// Start the RNG device.
7029    pub fn r#start(
7030        &self,
7031        mut start_info: StartInfo,
7032        ___deadline: zx::MonotonicInstant,
7033    ) -> Result<(), fidl::Error> {
7034        let _response = self
7035            .client
7036            .send_query::<VirtioRngStartRequest, fidl::encoding::EmptyPayload, VirtioRngMarker>(
7037                (&mut start_info,),
7038                0x620b3ed254febc0f,
7039                fidl::encoding::DynamicFlags::empty(),
7040                ___deadline,
7041            )?;
7042        Ok(_response)
7043    }
7044}
7045
7046#[cfg(target_os = "fuchsia")]
7047impl From<VirtioRngSynchronousProxy> for zx::NullableHandle {
7048    fn from(value: VirtioRngSynchronousProxy) -> Self {
7049        value.into_channel().into()
7050    }
7051}
7052
7053#[cfg(target_os = "fuchsia")]
7054impl From<fidl::Channel> for VirtioRngSynchronousProxy {
7055    fn from(value: fidl::Channel) -> Self {
7056        Self::new(value)
7057    }
7058}
7059
7060#[cfg(target_os = "fuchsia")]
7061impl fidl::endpoints::FromClient for VirtioRngSynchronousProxy {
7062    type Protocol = VirtioRngMarker;
7063
7064    fn from_client(value: fidl::endpoints::ClientEnd<VirtioRngMarker>) -> Self {
7065        Self::new(value.into_channel())
7066    }
7067}
7068
7069#[derive(Debug, Clone)]
7070pub struct VirtioRngProxy {
7071    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7072}
7073
7074impl fidl::endpoints::Proxy for VirtioRngProxy {
7075    type Protocol = VirtioRngMarker;
7076
7077    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7078        Self::new(inner)
7079    }
7080
7081    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7082        self.client.into_channel().map_err(|client| Self { client })
7083    }
7084
7085    fn as_channel(&self) -> &::fidl::AsyncChannel {
7086        self.client.as_channel()
7087    }
7088}
7089
7090impl VirtioRngProxy {
7091    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioRng.
7092    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7093        let protocol_name = <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7094        Self { client: fidl::client::Client::new(channel, protocol_name) }
7095    }
7096
7097    /// Get a Stream of events from the remote end of the protocol.
7098    ///
7099    /// # Panics
7100    ///
7101    /// Panics if the event stream was already taken.
7102    pub fn take_event_stream(&self) -> VirtioRngEventStream {
7103        VirtioRngEventStream { event_receiver: self.client.take_event_receiver() }
7104    }
7105
7106    /// Configure a `queue` for the device. This specifies the `size` and the
7107    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7108    pub fn r#configure_queue(
7109        &self,
7110        mut queue: u16,
7111        mut size: u16,
7112        mut desc: u64,
7113        mut avail: u64,
7114        mut used: u64,
7115    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7116        VirtioRngProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
7117    }
7118
7119    /// Notify a `queue` for the device. Primarily used for black-box testing.
7120    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7121        VirtioRngProxyInterface::r#notify_queue(self, queue)
7122    }
7123
7124    /// Ready a device. This provides the set of `negotiated_features` that the
7125    /// driver and device have agreed upon.
7126    pub fn r#ready(
7127        &self,
7128        mut negotiated_features: u32,
7129    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7130        VirtioRngProxyInterface::r#ready(self, negotiated_features)
7131    }
7132
7133    /// Start the RNG device.
7134    pub fn r#start(
7135        &self,
7136        mut start_info: StartInfo,
7137    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7138        VirtioRngProxyInterface::r#start(self, start_info)
7139    }
7140}
7141
7142impl VirtioRngProxyInterface for VirtioRngProxy {
7143    type ConfigureQueueResponseFut =
7144        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7145    fn r#configure_queue(
7146        &self,
7147        mut queue: u16,
7148        mut size: u16,
7149        mut desc: u64,
7150        mut avail: u64,
7151        mut used: u64,
7152    ) -> Self::ConfigureQueueResponseFut {
7153        fn _decode(
7154            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7155        ) -> Result<(), fidl::Error> {
7156            let _response = fidl::client::decode_transaction_body::<
7157                fidl::encoding::EmptyPayload,
7158                fidl::encoding::DefaultFuchsiaResourceDialect,
7159                0x72b44fb963480b11,
7160            >(_buf?)?;
7161            Ok(_response)
7162        }
7163        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
7164            (queue, size, desc, avail, used),
7165            0x72b44fb963480b11,
7166            fidl::encoding::DynamicFlags::empty(),
7167            _decode,
7168        )
7169    }
7170
7171    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7172        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7173            (queue,),
7174            0x6e3a61d652499244,
7175            fidl::encoding::DynamicFlags::empty(),
7176        )
7177    }
7178
7179    type ReadyResponseFut =
7180        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7181    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
7182        fn _decode(
7183            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7184        ) -> Result<(), fidl::Error> {
7185            let _response = fidl::client::decode_transaction_body::<
7186                fidl::encoding::EmptyPayload,
7187                fidl::encoding::DefaultFuchsiaResourceDialect,
7188                0x45707654f5d23c3f,
7189            >(_buf?)?;
7190            Ok(_response)
7191        }
7192        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
7193            (negotiated_features,),
7194            0x45707654f5d23c3f,
7195            fidl::encoding::DynamicFlags::empty(),
7196            _decode,
7197        )
7198    }
7199
7200    type StartResponseFut =
7201        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7202    fn r#start(&self, mut start_info: StartInfo) -> Self::StartResponseFut {
7203        fn _decode(
7204            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7205        ) -> Result<(), fidl::Error> {
7206            let _response = fidl::client::decode_transaction_body::<
7207                fidl::encoding::EmptyPayload,
7208                fidl::encoding::DefaultFuchsiaResourceDialect,
7209                0x620b3ed254febc0f,
7210            >(_buf?)?;
7211            Ok(_response)
7212        }
7213        self.client.send_query_and_decode::<VirtioRngStartRequest, ()>(
7214            (&mut start_info,),
7215            0x620b3ed254febc0f,
7216            fidl::encoding::DynamicFlags::empty(),
7217            _decode,
7218        )
7219    }
7220}
7221
7222pub struct VirtioRngEventStream {
7223    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7224}
7225
7226impl std::marker::Unpin for VirtioRngEventStream {}
7227
7228impl futures::stream::FusedStream for VirtioRngEventStream {
7229    fn is_terminated(&self) -> bool {
7230        self.event_receiver.is_terminated()
7231    }
7232}
7233
7234impl futures::Stream for VirtioRngEventStream {
7235    type Item = Result<VirtioRngEvent, fidl::Error>;
7236
7237    fn poll_next(
7238        mut self: std::pin::Pin<&mut Self>,
7239        cx: &mut std::task::Context<'_>,
7240    ) -> std::task::Poll<Option<Self::Item>> {
7241        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7242            &mut self.event_receiver,
7243            cx
7244        )?) {
7245            Some(buf) => std::task::Poll::Ready(Some(VirtioRngEvent::decode(buf))),
7246            None => std::task::Poll::Ready(None),
7247        }
7248    }
7249}
7250
7251#[derive(Debug)]
7252pub enum VirtioRngEvent {}
7253
7254impl VirtioRngEvent {
7255    /// Decodes a message buffer as a [`VirtioRngEvent`].
7256    fn decode(
7257        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7258    ) -> Result<VirtioRngEvent, fidl::Error> {
7259        let (bytes, _handles) = buf.split_mut();
7260        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7261        debug_assert_eq!(tx_header.tx_id, 0);
7262        match tx_header.ordinal {
7263            _ => Err(fidl::Error::UnknownOrdinal {
7264                ordinal: tx_header.ordinal,
7265                protocol_name: <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7266            }),
7267        }
7268    }
7269}
7270
7271/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioRng.
7272pub struct VirtioRngRequestStream {
7273    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7274    is_terminated: bool,
7275}
7276
7277impl std::marker::Unpin for VirtioRngRequestStream {}
7278
7279impl futures::stream::FusedStream for VirtioRngRequestStream {
7280    fn is_terminated(&self) -> bool {
7281        self.is_terminated
7282    }
7283}
7284
7285impl fidl::endpoints::RequestStream for VirtioRngRequestStream {
7286    type Protocol = VirtioRngMarker;
7287    type ControlHandle = VirtioRngControlHandle;
7288
7289    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7290        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7291    }
7292
7293    fn control_handle(&self) -> Self::ControlHandle {
7294        VirtioRngControlHandle { inner: self.inner.clone() }
7295    }
7296
7297    fn into_inner(
7298        self,
7299    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7300    {
7301        (self.inner, self.is_terminated)
7302    }
7303
7304    fn from_inner(
7305        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7306        is_terminated: bool,
7307    ) -> Self {
7308        Self { inner, is_terminated }
7309    }
7310}
7311
7312impl futures::Stream for VirtioRngRequestStream {
7313    type Item = Result<VirtioRngRequest, fidl::Error>;
7314
7315    fn poll_next(
7316        mut self: std::pin::Pin<&mut Self>,
7317        cx: &mut std::task::Context<'_>,
7318    ) -> std::task::Poll<Option<Self::Item>> {
7319        let this = &mut *self;
7320        if this.inner.check_shutdown(cx) {
7321            this.is_terminated = true;
7322            return std::task::Poll::Ready(None);
7323        }
7324        if this.is_terminated {
7325            panic!("polled VirtioRngRequestStream after completion");
7326        }
7327        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7328            |bytes, handles| {
7329                match this.inner.channel().read_etc(cx, bytes, handles) {
7330                    std::task::Poll::Ready(Ok(())) => {}
7331                    std::task::Poll::Pending => return std::task::Poll::Pending,
7332                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7333                        this.is_terminated = true;
7334                        return std::task::Poll::Ready(None);
7335                    }
7336                    std::task::Poll::Ready(Err(e)) => {
7337                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7338                            e.into(),
7339                        ))));
7340                    }
7341                }
7342
7343                // A message has been received from the channel
7344                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7345
7346                std::task::Poll::Ready(Some(match header.ordinal {
7347                    0x72b44fb963480b11 => {
7348                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7349                        let mut req = fidl::new_empty!(
7350                            VirtioDeviceConfigureQueueRequest,
7351                            fidl::encoding::DefaultFuchsiaResourceDialect
7352                        );
7353                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
7354                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
7355                        Ok(VirtioRngRequest::ConfigureQueue {
7356                            queue: req.queue,
7357                            size: req.size,
7358                            desc: req.desc,
7359                            avail: req.avail,
7360                            used: req.used,
7361
7362                            responder: VirtioRngConfigureQueueResponder {
7363                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7364                                tx_id: header.tx_id,
7365                            },
7366                        })
7367                    }
7368                    0x6e3a61d652499244 => {
7369                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7370                        let mut req = fidl::new_empty!(
7371                            VirtioDeviceNotifyQueueRequest,
7372                            fidl::encoding::DefaultFuchsiaResourceDialect
7373                        );
7374                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
7375                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
7376                        Ok(VirtioRngRequest::NotifyQueue { queue: req.queue, control_handle })
7377                    }
7378                    0x45707654f5d23c3f => {
7379                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7380                        let mut req = fidl::new_empty!(
7381                            VirtioDeviceReadyRequest,
7382                            fidl::encoding::DefaultFuchsiaResourceDialect
7383                        );
7384                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
7385                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
7386                        Ok(VirtioRngRequest::Ready {
7387                            negotiated_features: req.negotiated_features,
7388
7389                            responder: VirtioRngReadyResponder {
7390                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7391                                tx_id: header.tx_id,
7392                            },
7393                        })
7394                    }
7395                    0x620b3ed254febc0f => {
7396                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7397                        let mut req = fidl::new_empty!(
7398                            VirtioRngStartRequest,
7399                            fidl::encoding::DefaultFuchsiaResourceDialect
7400                        );
7401                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioRngStartRequest>(&header, _body_bytes, handles, &mut req)?;
7402                        let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
7403                        Ok(VirtioRngRequest::Start {
7404                            start_info: req.start_info,
7405
7406                            responder: VirtioRngStartResponder {
7407                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7408                                tx_id: header.tx_id,
7409                            },
7410                        })
7411                    }
7412                    _ => Err(fidl::Error::UnknownOrdinal {
7413                        ordinal: header.ordinal,
7414                        protocol_name:
7415                            <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7416                    }),
7417                }))
7418            },
7419        )
7420    }
7421}
7422
7423#[derive(Debug)]
7424pub enum VirtioRngRequest {
7425    /// Configure a `queue` for the device. This specifies the `size` and the
7426    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7427    ConfigureQueue {
7428        queue: u16,
7429        size: u16,
7430        desc: u64,
7431        avail: u64,
7432        used: u64,
7433        responder: VirtioRngConfigureQueueResponder,
7434    },
7435    /// Notify a `queue` for the device. Primarily used for black-box testing.
7436    NotifyQueue { queue: u16, control_handle: VirtioRngControlHandle },
7437    /// Ready a device. This provides the set of `negotiated_features` that the
7438    /// driver and device have agreed upon.
7439    Ready { negotiated_features: u32, responder: VirtioRngReadyResponder },
7440    /// Start the RNG device.
7441    Start { start_info: StartInfo, responder: VirtioRngStartResponder },
7442}
7443
7444impl VirtioRngRequest {
7445    #[allow(irrefutable_let_patterns)]
7446    pub fn into_configure_queue(
7447        self,
7448    ) -> Option<(u16, u16, u64, u64, u64, VirtioRngConfigureQueueResponder)> {
7449        if let VirtioRngRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
7450        {
7451            Some((queue, size, desc, avail, used, responder))
7452        } else {
7453            None
7454        }
7455    }
7456
7457    #[allow(irrefutable_let_patterns)]
7458    pub fn into_notify_queue(self) -> Option<(u16, VirtioRngControlHandle)> {
7459        if let VirtioRngRequest::NotifyQueue { queue, control_handle } = self {
7460            Some((queue, control_handle))
7461        } else {
7462            None
7463        }
7464    }
7465
7466    #[allow(irrefutable_let_patterns)]
7467    pub fn into_ready(self) -> Option<(u32, VirtioRngReadyResponder)> {
7468        if let VirtioRngRequest::Ready { negotiated_features, responder } = self {
7469            Some((negotiated_features, responder))
7470        } else {
7471            None
7472        }
7473    }
7474
7475    #[allow(irrefutable_let_patterns)]
7476    pub fn into_start(self) -> Option<(StartInfo, VirtioRngStartResponder)> {
7477        if let VirtioRngRequest::Start { start_info, responder } = self {
7478            Some((start_info, responder))
7479        } else {
7480            None
7481        }
7482    }
7483
7484    /// Name of the method defined in FIDL
7485    pub fn method_name(&self) -> &'static str {
7486        match *self {
7487            VirtioRngRequest::ConfigureQueue { .. } => "configure_queue",
7488            VirtioRngRequest::NotifyQueue { .. } => "notify_queue",
7489            VirtioRngRequest::Ready { .. } => "ready",
7490            VirtioRngRequest::Start { .. } => "start",
7491        }
7492    }
7493}
7494
7495#[derive(Debug, Clone)]
7496pub struct VirtioRngControlHandle {
7497    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7498}
7499
7500impl fidl::endpoints::ControlHandle for VirtioRngControlHandle {
7501    fn shutdown(&self) {
7502        self.inner.shutdown()
7503    }
7504
7505    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7506        self.inner.shutdown_with_epitaph(status)
7507    }
7508
7509    fn is_closed(&self) -> bool {
7510        self.inner.channel().is_closed()
7511    }
7512    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7513        self.inner.channel().on_closed()
7514    }
7515
7516    #[cfg(target_os = "fuchsia")]
7517    fn signal_peer(
7518        &self,
7519        clear_mask: zx::Signals,
7520        set_mask: zx::Signals,
7521    ) -> Result<(), zx_status::Status> {
7522        use fidl::Peered;
7523        self.inner.channel().signal_peer(clear_mask, set_mask)
7524    }
7525}
7526
7527impl VirtioRngControlHandle {}
7528
7529#[must_use = "FIDL methods require a response to be sent"]
7530#[derive(Debug)]
7531pub struct VirtioRngConfigureQueueResponder {
7532    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
7533    tx_id: u32,
7534}
7535
7536/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
7537/// if the responder is dropped without sending a response, so that the client
7538/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7539impl std::ops::Drop for VirtioRngConfigureQueueResponder {
7540    fn drop(&mut self) {
7541        self.control_handle.shutdown();
7542        // Safety: drops once, never accessed again
7543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7544    }
7545}
7546
7547impl fidl::endpoints::Responder for VirtioRngConfigureQueueResponder {
7548    type ControlHandle = VirtioRngControlHandle;
7549
7550    fn control_handle(&self) -> &VirtioRngControlHandle {
7551        &self.control_handle
7552    }
7553
7554    fn drop_without_shutdown(mut self) {
7555        // Safety: drops once, never accessed again due to mem::forget
7556        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7557        // Prevent Drop from running (which would shut down the channel)
7558        std::mem::forget(self);
7559    }
7560}
7561
7562impl VirtioRngConfigureQueueResponder {
7563    /// Sends a response to the FIDL transaction.
7564    ///
7565    /// Sets the channel to shutdown if an error occurs.
7566    pub fn send(self) -> Result<(), fidl::Error> {
7567        let _result = self.send_raw();
7568        if _result.is_err() {
7569            self.control_handle.shutdown();
7570        }
7571        self.drop_without_shutdown();
7572        _result
7573    }
7574
7575    /// Similar to "send" but does not shutdown the channel if an error occurs.
7576    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7577        let _result = self.send_raw();
7578        self.drop_without_shutdown();
7579        _result
7580    }
7581
7582    fn send_raw(&self) -> Result<(), fidl::Error> {
7583        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7584            (),
7585            self.tx_id,
7586            0x72b44fb963480b11,
7587            fidl::encoding::DynamicFlags::empty(),
7588        )
7589    }
7590}
7591
7592#[must_use = "FIDL methods require a response to be sent"]
7593#[derive(Debug)]
7594pub struct VirtioRngReadyResponder {
7595    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
7596    tx_id: u32,
7597}
7598
7599/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
7600/// if the responder is dropped without sending a response, so that the client
7601/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7602impl std::ops::Drop for VirtioRngReadyResponder {
7603    fn drop(&mut self) {
7604        self.control_handle.shutdown();
7605        // Safety: drops once, never accessed again
7606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7607    }
7608}
7609
7610impl fidl::endpoints::Responder for VirtioRngReadyResponder {
7611    type ControlHandle = VirtioRngControlHandle;
7612
7613    fn control_handle(&self) -> &VirtioRngControlHandle {
7614        &self.control_handle
7615    }
7616
7617    fn drop_without_shutdown(mut self) {
7618        // Safety: drops once, never accessed again due to mem::forget
7619        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7620        // Prevent Drop from running (which would shut down the channel)
7621        std::mem::forget(self);
7622    }
7623}
7624
7625impl VirtioRngReadyResponder {
7626    /// Sends a response to the FIDL transaction.
7627    ///
7628    /// Sets the channel to shutdown if an error occurs.
7629    pub fn send(self) -> Result<(), fidl::Error> {
7630        let _result = self.send_raw();
7631        if _result.is_err() {
7632            self.control_handle.shutdown();
7633        }
7634        self.drop_without_shutdown();
7635        _result
7636    }
7637
7638    /// Similar to "send" but does not shutdown the channel if an error occurs.
7639    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7640        let _result = self.send_raw();
7641        self.drop_without_shutdown();
7642        _result
7643    }
7644
7645    fn send_raw(&self) -> Result<(), fidl::Error> {
7646        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7647            (),
7648            self.tx_id,
7649            0x45707654f5d23c3f,
7650            fidl::encoding::DynamicFlags::empty(),
7651        )
7652    }
7653}
7654
7655#[must_use = "FIDL methods require a response to be sent"]
7656#[derive(Debug)]
7657pub struct VirtioRngStartResponder {
7658    control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
7659    tx_id: u32,
7660}
7661
7662/// Set the the channel to be shutdown (see [`VirtioRngControlHandle::shutdown`])
7663/// if the responder is dropped without sending a response, so that the client
7664/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7665impl std::ops::Drop for VirtioRngStartResponder {
7666    fn drop(&mut self) {
7667        self.control_handle.shutdown();
7668        // Safety: drops once, never accessed again
7669        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7670    }
7671}
7672
7673impl fidl::endpoints::Responder for VirtioRngStartResponder {
7674    type ControlHandle = VirtioRngControlHandle;
7675
7676    fn control_handle(&self) -> &VirtioRngControlHandle {
7677        &self.control_handle
7678    }
7679
7680    fn drop_without_shutdown(mut self) {
7681        // Safety: drops once, never accessed again due to mem::forget
7682        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7683        // Prevent Drop from running (which would shut down the channel)
7684        std::mem::forget(self);
7685    }
7686}
7687
7688impl VirtioRngStartResponder {
7689    /// Sends a response to the FIDL transaction.
7690    ///
7691    /// Sets the channel to shutdown if an error occurs.
7692    pub fn send(self) -> Result<(), fidl::Error> {
7693        let _result = self.send_raw();
7694        if _result.is_err() {
7695            self.control_handle.shutdown();
7696        }
7697        self.drop_without_shutdown();
7698        _result
7699    }
7700
7701    /// Similar to "send" but does not shutdown the channel if an error occurs.
7702    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7703        let _result = self.send_raw();
7704        self.drop_without_shutdown();
7705        _result
7706    }
7707
7708    fn send_raw(&self) -> Result<(), fidl::Error> {
7709        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7710            (),
7711            self.tx_id,
7712            0x620b3ed254febc0f,
7713            fidl::encoding::DynamicFlags::empty(),
7714        )
7715    }
7716}
7717
7718#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7719pub struct VirtioSoundMarker;
7720
7721impl fidl::endpoints::ProtocolMarker for VirtioSoundMarker {
7722    type Proxy = VirtioSoundProxy;
7723    type RequestStream = VirtioSoundRequestStream;
7724    #[cfg(target_os = "fuchsia")]
7725    type SynchronousProxy = VirtioSoundSynchronousProxy;
7726
7727    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioSound";
7728}
7729impl fidl::endpoints::DiscoverableProtocolMarker for VirtioSoundMarker {}
7730
7731pub trait VirtioSoundProxyInterface: Send + Sync {
7732    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7733    fn r#configure_queue(
7734        &self,
7735        queue: u16,
7736        size: u16,
7737        desc: u64,
7738        avail: u64,
7739        used: u64,
7740    ) -> Self::ConfigureQueueResponseFut;
7741    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
7742    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7743    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
7744    type StartResponseFut: std::future::Future<Output = Result<(u32, u32, u32, u32), fidl::Error>>
7745        + Send;
7746    fn r#start(
7747        &self,
7748        start_info: StartInfo,
7749        enable_input: bool,
7750        enable_verbose_logging: bool,
7751    ) -> Self::StartResponseFut;
7752}
7753#[derive(Debug)]
7754#[cfg(target_os = "fuchsia")]
7755pub struct VirtioSoundSynchronousProxy {
7756    client: fidl::client::sync::Client,
7757}
7758
7759#[cfg(target_os = "fuchsia")]
7760impl fidl::endpoints::SynchronousProxy for VirtioSoundSynchronousProxy {
7761    type Proxy = VirtioSoundProxy;
7762    type Protocol = VirtioSoundMarker;
7763
7764    fn from_channel(inner: fidl::Channel) -> Self {
7765        Self::new(inner)
7766    }
7767
7768    fn into_channel(self) -> fidl::Channel {
7769        self.client.into_channel()
7770    }
7771
7772    fn as_channel(&self) -> &fidl::Channel {
7773        self.client.as_channel()
7774    }
7775}
7776
7777#[cfg(target_os = "fuchsia")]
7778impl VirtioSoundSynchronousProxy {
7779    pub fn new(channel: fidl::Channel) -> Self {
7780        Self { client: fidl::client::sync::Client::new(channel) }
7781    }
7782
7783    pub fn into_channel(self) -> fidl::Channel {
7784        self.client.into_channel()
7785    }
7786
7787    /// Waits until an event arrives and returns it. It is safe for other
7788    /// threads to make concurrent requests while waiting for an event.
7789    pub fn wait_for_event(
7790        &self,
7791        deadline: zx::MonotonicInstant,
7792    ) -> Result<VirtioSoundEvent, fidl::Error> {
7793        VirtioSoundEvent::decode(self.client.wait_for_event::<VirtioSoundMarker>(deadline)?)
7794    }
7795
7796    /// Configure a `queue` for the device. This specifies the `size` and the
7797    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7798    pub fn r#configure_queue(
7799        &self,
7800        mut queue: u16,
7801        mut size: u16,
7802        mut desc: u64,
7803        mut avail: u64,
7804        mut used: u64,
7805        ___deadline: zx::MonotonicInstant,
7806    ) -> Result<(), fidl::Error> {
7807        let _response = self.client.send_query::<
7808            VirtioDeviceConfigureQueueRequest,
7809            fidl::encoding::EmptyPayload,
7810            VirtioSoundMarker,
7811        >(
7812            (queue, size, desc, avail, used,),
7813            0x72b44fb963480b11,
7814            fidl::encoding::DynamicFlags::empty(),
7815            ___deadline,
7816        )?;
7817        Ok(_response)
7818    }
7819
7820    /// Notify a `queue` for the device. Primarily used for black-box testing.
7821    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7822        self.client.send::<VirtioDeviceNotifyQueueRequest>(
7823            (queue,),
7824            0x6e3a61d652499244,
7825            fidl::encoding::DynamicFlags::empty(),
7826        )
7827    }
7828
7829    /// Ready a device. This provides the set of `negotiated_features` that the
7830    /// driver and device have agreed upon.
7831    pub fn r#ready(
7832        &self,
7833        mut negotiated_features: u32,
7834        ___deadline: zx::MonotonicInstant,
7835    ) -> Result<(), fidl::Error> {
7836        let _response = self.client.send_query::<
7837            VirtioDeviceReadyRequest,
7838            fidl::encoding::EmptyPayload,
7839            VirtioSoundMarker,
7840        >(
7841            (negotiated_features,),
7842            0x45707654f5d23c3f,
7843            fidl::encoding::DynamicFlags::empty(),
7844            ___deadline,
7845        )?;
7846        Ok(_response)
7847    }
7848
7849    /// Start the sound device.
7850    /// The response contains the device's expected static configuration.
7851    ///
7852    /// + request `start_info` basic info to start the device
7853    /// + request `enable_input` whether audio input (capture) should be enabled
7854    /// + request `enable_verbose_logging` whether verbose logging should be enabled
7855    /// - response `features` supported features
7856    /// - response `jacks` the virtio_snd_config.jacks value to advertise
7857    /// - response `streams` the virtio_snd_config.streams value to advertise
7858    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
7859    pub fn r#start(
7860        &self,
7861        mut start_info: StartInfo,
7862        mut enable_input: bool,
7863        mut enable_verbose_logging: bool,
7864        ___deadline: zx::MonotonicInstant,
7865    ) -> Result<(u32, u32, u32, u32), fidl::Error> {
7866        let _response = self
7867            .client
7868            .send_query::<VirtioSoundStartRequest, VirtioSoundStartResponse, VirtioSoundMarker>(
7869                (&mut start_info, enable_input, enable_verbose_logging),
7870                0x2c3a5528c0b92e2d,
7871                fidl::encoding::DynamicFlags::empty(),
7872                ___deadline,
7873            )?;
7874        Ok((_response.features, _response.jacks, _response.streams, _response.chmaps))
7875    }
7876}
7877
7878#[cfg(target_os = "fuchsia")]
7879impl From<VirtioSoundSynchronousProxy> for zx::NullableHandle {
7880    fn from(value: VirtioSoundSynchronousProxy) -> Self {
7881        value.into_channel().into()
7882    }
7883}
7884
7885#[cfg(target_os = "fuchsia")]
7886impl From<fidl::Channel> for VirtioSoundSynchronousProxy {
7887    fn from(value: fidl::Channel) -> Self {
7888        Self::new(value)
7889    }
7890}
7891
7892#[cfg(target_os = "fuchsia")]
7893impl fidl::endpoints::FromClient for VirtioSoundSynchronousProxy {
7894    type Protocol = VirtioSoundMarker;
7895
7896    fn from_client(value: fidl::endpoints::ClientEnd<VirtioSoundMarker>) -> Self {
7897        Self::new(value.into_channel())
7898    }
7899}
7900
7901#[derive(Debug, Clone)]
7902pub struct VirtioSoundProxy {
7903    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7904}
7905
7906impl fidl::endpoints::Proxy for VirtioSoundProxy {
7907    type Protocol = VirtioSoundMarker;
7908
7909    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7910        Self::new(inner)
7911    }
7912
7913    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7914        self.client.into_channel().map_err(|client| Self { client })
7915    }
7916
7917    fn as_channel(&self) -> &::fidl::AsyncChannel {
7918        self.client.as_channel()
7919    }
7920}
7921
7922impl VirtioSoundProxy {
7923    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioSound.
7924    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7925        let protocol_name = <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7926        Self { client: fidl::client::Client::new(channel, protocol_name) }
7927    }
7928
7929    /// Get a Stream of events from the remote end of the protocol.
7930    ///
7931    /// # Panics
7932    ///
7933    /// Panics if the event stream was already taken.
7934    pub fn take_event_stream(&self) -> VirtioSoundEventStream {
7935        VirtioSoundEventStream { event_receiver: self.client.take_event_receiver() }
7936    }
7937
7938    /// Configure a `queue` for the device. This specifies the `size` and the
7939    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
7940    pub fn r#configure_queue(
7941        &self,
7942        mut queue: u16,
7943        mut size: u16,
7944        mut desc: u64,
7945        mut avail: u64,
7946        mut used: u64,
7947    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7948        VirtioSoundProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
7949    }
7950
7951    /// Notify a `queue` for the device. Primarily used for black-box testing.
7952    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
7953        VirtioSoundProxyInterface::r#notify_queue(self, queue)
7954    }
7955
7956    /// Ready a device. This provides the set of `negotiated_features` that the
7957    /// driver and device have agreed upon.
7958    pub fn r#ready(
7959        &self,
7960        mut negotiated_features: u32,
7961    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7962        VirtioSoundProxyInterface::r#ready(self, negotiated_features)
7963    }
7964
7965    /// Start the sound device.
7966    /// The response contains the device's expected static configuration.
7967    ///
7968    /// + request `start_info` basic info to start the device
7969    /// + request `enable_input` whether audio input (capture) should be enabled
7970    /// + request `enable_verbose_logging` whether verbose logging should be enabled
7971    /// - response `features` supported features
7972    /// - response `jacks` the virtio_snd_config.jacks value to advertise
7973    /// - response `streams` the virtio_snd_config.streams value to advertise
7974    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
7975    pub fn r#start(
7976        &self,
7977        mut start_info: StartInfo,
7978        mut enable_input: bool,
7979        mut enable_verbose_logging: bool,
7980    ) -> fidl::client::QueryResponseFut<
7981        (u32, u32, u32, u32),
7982        fidl::encoding::DefaultFuchsiaResourceDialect,
7983    > {
7984        VirtioSoundProxyInterface::r#start(self, start_info, enable_input, enable_verbose_logging)
7985    }
7986}
7987
7988impl VirtioSoundProxyInterface for VirtioSoundProxy {
7989    type ConfigureQueueResponseFut =
7990        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7991    fn r#configure_queue(
7992        &self,
7993        mut queue: u16,
7994        mut size: u16,
7995        mut desc: u64,
7996        mut avail: u64,
7997        mut used: u64,
7998    ) -> Self::ConfigureQueueResponseFut {
7999        fn _decode(
8000            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8001        ) -> Result<(), fidl::Error> {
8002            let _response = fidl::client::decode_transaction_body::<
8003                fidl::encoding::EmptyPayload,
8004                fidl::encoding::DefaultFuchsiaResourceDialect,
8005                0x72b44fb963480b11,
8006            >(_buf?)?;
8007            Ok(_response)
8008        }
8009        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
8010            (queue, size, desc, avail, used),
8011            0x72b44fb963480b11,
8012            fidl::encoding::DynamicFlags::empty(),
8013            _decode,
8014        )
8015    }
8016
8017    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8018        self.client.send::<VirtioDeviceNotifyQueueRequest>(
8019            (queue,),
8020            0x6e3a61d652499244,
8021            fidl::encoding::DynamicFlags::empty(),
8022        )
8023    }
8024
8025    type ReadyResponseFut =
8026        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8027    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
8028        fn _decode(
8029            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8030        ) -> Result<(), fidl::Error> {
8031            let _response = fidl::client::decode_transaction_body::<
8032                fidl::encoding::EmptyPayload,
8033                fidl::encoding::DefaultFuchsiaResourceDialect,
8034                0x45707654f5d23c3f,
8035            >(_buf?)?;
8036            Ok(_response)
8037        }
8038        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
8039            (negotiated_features,),
8040            0x45707654f5d23c3f,
8041            fidl::encoding::DynamicFlags::empty(),
8042            _decode,
8043        )
8044    }
8045
8046    type StartResponseFut = fidl::client::QueryResponseFut<
8047        (u32, u32, u32, u32),
8048        fidl::encoding::DefaultFuchsiaResourceDialect,
8049    >;
8050    fn r#start(
8051        &self,
8052        mut start_info: StartInfo,
8053        mut enable_input: bool,
8054        mut enable_verbose_logging: bool,
8055    ) -> Self::StartResponseFut {
8056        fn _decode(
8057            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8058        ) -> Result<(u32, u32, u32, u32), fidl::Error> {
8059            let _response = fidl::client::decode_transaction_body::<
8060                VirtioSoundStartResponse,
8061                fidl::encoding::DefaultFuchsiaResourceDialect,
8062                0x2c3a5528c0b92e2d,
8063            >(_buf?)?;
8064            Ok((_response.features, _response.jacks, _response.streams, _response.chmaps))
8065        }
8066        self.client.send_query_and_decode::<VirtioSoundStartRequest, (u32, u32, u32, u32)>(
8067            (&mut start_info, enable_input, enable_verbose_logging),
8068            0x2c3a5528c0b92e2d,
8069            fidl::encoding::DynamicFlags::empty(),
8070            _decode,
8071        )
8072    }
8073}
8074
8075pub struct VirtioSoundEventStream {
8076    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8077}
8078
8079impl std::marker::Unpin for VirtioSoundEventStream {}
8080
8081impl futures::stream::FusedStream for VirtioSoundEventStream {
8082    fn is_terminated(&self) -> bool {
8083        self.event_receiver.is_terminated()
8084    }
8085}
8086
8087impl futures::Stream for VirtioSoundEventStream {
8088    type Item = Result<VirtioSoundEvent, fidl::Error>;
8089
8090    fn poll_next(
8091        mut self: std::pin::Pin<&mut Self>,
8092        cx: &mut std::task::Context<'_>,
8093    ) -> std::task::Poll<Option<Self::Item>> {
8094        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8095            &mut self.event_receiver,
8096            cx
8097        )?) {
8098            Some(buf) => std::task::Poll::Ready(Some(VirtioSoundEvent::decode(buf))),
8099            None => std::task::Poll::Ready(None),
8100        }
8101    }
8102}
8103
8104#[derive(Debug)]
8105pub enum VirtioSoundEvent {}
8106
8107impl VirtioSoundEvent {
8108    /// Decodes a message buffer as a [`VirtioSoundEvent`].
8109    fn decode(
8110        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8111    ) -> Result<VirtioSoundEvent, fidl::Error> {
8112        let (bytes, _handles) = buf.split_mut();
8113        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8114        debug_assert_eq!(tx_header.tx_id, 0);
8115        match tx_header.ordinal {
8116            _ => Err(fidl::Error::UnknownOrdinal {
8117                ordinal: tx_header.ordinal,
8118                protocol_name: <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8119            }),
8120        }
8121    }
8122}
8123
8124/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioSound.
8125pub struct VirtioSoundRequestStream {
8126    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8127    is_terminated: bool,
8128}
8129
8130impl std::marker::Unpin for VirtioSoundRequestStream {}
8131
8132impl futures::stream::FusedStream for VirtioSoundRequestStream {
8133    fn is_terminated(&self) -> bool {
8134        self.is_terminated
8135    }
8136}
8137
8138impl fidl::endpoints::RequestStream for VirtioSoundRequestStream {
8139    type Protocol = VirtioSoundMarker;
8140    type ControlHandle = VirtioSoundControlHandle;
8141
8142    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8143        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8144    }
8145
8146    fn control_handle(&self) -> Self::ControlHandle {
8147        VirtioSoundControlHandle { inner: self.inner.clone() }
8148    }
8149
8150    fn into_inner(
8151        self,
8152    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8153    {
8154        (self.inner, self.is_terminated)
8155    }
8156
8157    fn from_inner(
8158        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8159        is_terminated: bool,
8160    ) -> Self {
8161        Self { inner, is_terminated }
8162    }
8163}
8164
8165impl futures::Stream for VirtioSoundRequestStream {
8166    type Item = Result<VirtioSoundRequest, fidl::Error>;
8167
8168    fn poll_next(
8169        mut self: std::pin::Pin<&mut Self>,
8170        cx: &mut std::task::Context<'_>,
8171    ) -> std::task::Poll<Option<Self::Item>> {
8172        let this = &mut *self;
8173        if this.inner.check_shutdown(cx) {
8174            this.is_terminated = true;
8175            return std::task::Poll::Ready(None);
8176        }
8177        if this.is_terminated {
8178            panic!("polled VirtioSoundRequestStream after completion");
8179        }
8180        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8181            |bytes, handles| {
8182                match this.inner.channel().read_etc(cx, bytes, handles) {
8183                    std::task::Poll::Ready(Ok(())) => {}
8184                    std::task::Poll::Pending => return std::task::Poll::Pending,
8185                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8186                        this.is_terminated = true;
8187                        return std::task::Poll::Ready(None);
8188                    }
8189                    std::task::Poll::Ready(Err(e)) => {
8190                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8191                            e.into(),
8192                        ))));
8193                    }
8194                }
8195
8196                // A message has been received from the channel
8197                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8198
8199                std::task::Poll::Ready(Some(match header.ordinal {
8200                    0x72b44fb963480b11 => {
8201                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8202                        let mut req = fidl::new_empty!(
8203                            VirtioDeviceConfigureQueueRequest,
8204                            fidl::encoding::DefaultFuchsiaResourceDialect
8205                        );
8206                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
8207                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
8208                        Ok(VirtioSoundRequest::ConfigureQueue {
8209                            queue: req.queue,
8210                            size: req.size,
8211                            desc: req.desc,
8212                            avail: req.avail,
8213                            used: req.used,
8214
8215                            responder: VirtioSoundConfigureQueueResponder {
8216                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8217                                tx_id: header.tx_id,
8218                            },
8219                        })
8220                    }
8221                    0x6e3a61d652499244 => {
8222                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8223                        let mut req = fidl::new_empty!(
8224                            VirtioDeviceNotifyQueueRequest,
8225                            fidl::encoding::DefaultFuchsiaResourceDialect
8226                        );
8227                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
8228                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
8229                        Ok(VirtioSoundRequest::NotifyQueue { queue: req.queue, control_handle })
8230                    }
8231                    0x45707654f5d23c3f => {
8232                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8233                        let mut req = fidl::new_empty!(
8234                            VirtioDeviceReadyRequest,
8235                            fidl::encoding::DefaultFuchsiaResourceDialect
8236                        );
8237                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
8238                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
8239                        Ok(VirtioSoundRequest::Ready {
8240                            negotiated_features: req.negotiated_features,
8241
8242                            responder: VirtioSoundReadyResponder {
8243                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8244                                tx_id: header.tx_id,
8245                            },
8246                        })
8247                    }
8248                    0x2c3a5528c0b92e2d => {
8249                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8250                        let mut req = fidl::new_empty!(
8251                            VirtioSoundStartRequest,
8252                            fidl::encoding::DefaultFuchsiaResourceDialect
8253                        );
8254                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioSoundStartRequest>(&header, _body_bytes, handles, &mut req)?;
8255                        let control_handle = VirtioSoundControlHandle { inner: this.inner.clone() };
8256                        Ok(VirtioSoundRequest::Start {
8257                            start_info: req.start_info,
8258                            enable_input: req.enable_input,
8259                            enable_verbose_logging: req.enable_verbose_logging,
8260
8261                            responder: VirtioSoundStartResponder {
8262                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8263                                tx_id: header.tx_id,
8264                            },
8265                        })
8266                    }
8267                    _ => Err(fidl::Error::UnknownOrdinal {
8268                        ordinal: header.ordinal,
8269                        protocol_name:
8270                            <VirtioSoundMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8271                    }),
8272                }))
8273            },
8274        )
8275    }
8276}
8277
8278#[derive(Debug)]
8279pub enum VirtioSoundRequest {
8280    /// Configure a `queue` for the device. This specifies the `size` and the
8281    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8282    ConfigureQueue {
8283        queue: u16,
8284        size: u16,
8285        desc: u64,
8286        avail: u64,
8287        used: u64,
8288        responder: VirtioSoundConfigureQueueResponder,
8289    },
8290    /// Notify a `queue` for the device. Primarily used for black-box testing.
8291    NotifyQueue { queue: u16, control_handle: VirtioSoundControlHandle },
8292    /// Ready a device. This provides the set of `negotiated_features` that the
8293    /// driver and device have agreed upon.
8294    Ready { negotiated_features: u32, responder: VirtioSoundReadyResponder },
8295    /// Start the sound device.
8296    /// The response contains the device's expected static configuration.
8297    ///
8298    /// + request `start_info` basic info to start the device
8299    /// + request `enable_input` whether audio input (capture) should be enabled
8300    /// + request `enable_verbose_logging` whether verbose logging should be enabled
8301    /// - response `features` supported features
8302    /// - response `jacks` the virtio_snd_config.jacks value to advertise
8303    /// - response `streams` the virtio_snd_config.streams value to advertise
8304    /// - response `chmaps` the virtio_snd_config.chaps value to advertise
8305    Start {
8306        start_info: StartInfo,
8307        enable_input: bool,
8308        enable_verbose_logging: bool,
8309        responder: VirtioSoundStartResponder,
8310    },
8311}
8312
8313impl VirtioSoundRequest {
8314    #[allow(irrefutable_let_patterns)]
8315    pub fn into_configure_queue(
8316        self,
8317    ) -> Option<(u16, u16, u64, u64, u64, VirtioSoundConfigureQueueResponder)> {
8318        if let VirtioSoundRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
8319            self
8320        {
8321            Some((queue, size, desc, avail, used, responder))
8322        } else {
8323            None
8324        }
8325    }
8326
8327    #[allow(irrefutable_let_patterns)]
8328    pub fn into_notify_queue(self) -> Option<(u16, VirtioSoundControlHandle)> {
8329        if let VirtioSoundRequest::NotifyQueue { queue, control_handle } = self {
8330            Some((queue, control_handle))
8331        } else {
8332            None
8333        }
8334    }
8335
8336    #[allow(irrefutable_let_patterns)]
8337    pub fn into_ready(self) -> Option<(u32, VirtioSoundReadyResponder)> {
8338        if let VirtioSoundRequest::Ready { negotiated_features, responder } = self {
8339            Some((negotiated_features, responder))
8340        } else {
8341            None
8342        }
8343    }
8344
8345    #[allow(irrefutable_let_patterns)]
8346    pub fn into_start(self) -> Option<(StartInfo, bool, bool, VirtioSoundStartResponder)> {
8347        if let VirtioSoundRequest::Start {
8348            start_info,
8349            enable_input,
8350            enable_verbose_logging,
8351            responder,
8352        } = self
8353        {
8354            Some((start_info, enable_input, enable_verbose_logging, responder))
8355        } else {
8356            None
8357        }
8358    }
8359
8360    /// Name of the method defined in FIDL
8361    pub fn method_name(&self) -> &'static str {
8362        match *self {
8363            VirtioSoundRequest::ConfigureQueue { .. } => "configure_queue",
8364            VirtioSoundRequest::NotifyQueue { .. } => "notify_queue",
8365            VirtioSoundRequest::Ready { .. } => "ready",
8366            VirtioSoundRequest::Start { .. } => "start",
8367        }
8368    }
8369}
8370
8371#[derive(Debug, Clone)]
8372pub struct VirtioSoundControlHandle {
8373    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8374}
8375
8376impl fidl::endpoints::ControlHandle for VirtioSoundControlHandle {
8377    fn shutdown(&self) {
8378        self.inner.shutdown()
8379    }
8380
8381    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8382        self.inner.shutdown_with_epitaph(status)
8383    }
8384
8385    fn is_closed(&self) -> bool {
8386        self.inner.channel().is_closed()
8387    }
8388    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8389        self.inner.channel().on_closed()
8390    }
8391
8392    #[cfg(target_os = "fuchsia")]
8393    fn signal_peer(
8394        &self,
8395        clear_mask: zx::Signals,
8396        set_mask: zx::Signals,
8397    ) -> Result<(), zx_status::Status> {
8398        use fidl::Peered;
8399        self.inner.channel().signal_peer(clear_mask, set_mask)
8400    }
8401}
8402
8403impl VirtioSoundControlHandle {}
8404
8405#[must_use = "FIDL methods require a response to be sent"]
8406#[derive(Debug)]
8407pub struct VirtioSoundConfigureQueueResponder {
8408    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
8409    tx_id: u32,
8410}
8411
8412/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
8413/// if the responder is dropped without sending a response, so that the client
8414/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8415impl std::ops::Drop for VirtioSoundConfigureQueueResponder {
8416    fn drop(&mut self) {
8417        self.control_handle.shutdown();
8418        // Safety: drops once, never accessed again
8419        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8420    }
8421}
8422
8423impl fidl::endpoints::Responder for VirtioSoundConfigureQueueResponder {
8424    type ControlHandle = VirtioSoundControlHandle;
8425
8426    fn control_handle(&self) -> &VirtioSoundControlHandle {
8427        &self.control_handle
8428    }
8429
8430    fn drop_without_shutdown(mut self) {
8431        // Safety: drops once, never accessed again due to mem::forget
8432        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8433        // Prevent Drop from running (which would shut down the channel)
8434        std::mem::forget(self);
8435    }
8436}
8437
8438impl VirtioSoundConfigureQueueResponder {
8439    /// Sends a response to the FIDL transaction.
8440    ///
8441    /// Sets the channel to shutdown if an error occurs.
8442    pub fn send(self) -> Result<(), fidl::Error> {
8443        let _result = self.send_raw();
8444        if _result.is_err() {
8445            self.control_handle.shutdown();
8446        }
8447        self.drop_without_shutdown();
8448        _result
8449    }
8450
8451    /// Similar to "send" but does not shutdown the channel if an error occurs.
8452    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8453        let _result = self.send_raw();
8454        self.drop_without_shutdown();
8455        _result
8456    }
8457
8458    fn send_raw(&self) -> Result<(), fidl::Error> {
8459        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8460            (),
8461            self.tx_id,
8462            0x72b44fb963480b11,
8463            fidl::encoding::DynamicFlags::empty(),
8464        )
8465    }
8466}
8467
8468#[must_use = "FIDL methods require a response to be sent"]
8469#[derive(Debug)]
8470pub struct VirtioSoundReadyResponder {
8471    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
8472    tx_id: u32,
8473}
8474
8475/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
8476/// if the responder is dropped without sending a response, so that the client
8477/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8478impl std::ops::Drop for VirtioSoundReadyResponder {
8479    fn drop(&mut self) {
8480        self.control_handle.shutdown();
8481        // Safety: drops once, never accessed again
8482        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8483    }
8484}
8485
8486impl fidl::endpoints::Responder for VirtioSoundReadyResponder {
8487    type ControlHandle = VirtioSoundControlHandle;
8488
8489    fn control_handle(&self) -> &VirtioSoundControlHandle {
8490        &self.control_handle
8491    }
8492
8493    fn drop_without_shutdown(mut self) {
8494        // Safety: drops once, never accessed again due to mem::forget
8495        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8496        // Prevent Drop from running (which would shut down the channel)
8497        std::mem::forget(self);
8498    }
8499}
8500
8501impl VirtioSoundReadyResponder {
8502    /// Sends a response to the FIDL transaction.
8503    ///
8504    /// Sets the channel to shutdown if an error occurs.
8505    pub fn send(self) -> Result<(), fidl::Error> {
8506        let _result = self.send_raw();
8507        if _result.is_err() {
8508            self.control_handle.shutdown();
8509        }
8510        self.drop_without_shutdown();
8511        _result
8512    }
8513
8514    /// Similar to "send" but does not shutdown the channel if an error occurs.
8515    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8516        let _result = self.send_raw();
8517        self.drop_without_shutdown();
8518        _result
8519    }
8520
8521    fn send_raw(&self) -> Result<(), fidl::Error> {
8522        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8523            (),
8524            self.tx_id,
8525            0x45707654f5d23c3f,
8526            fidl::encoding::DynamicFlags::empty(),
8527        )
8528    }
8529}
8530
8531#[must_use = "FIDL methods require a response to be sent"]
8532#[derive(Debug)]
8533pub struct VirtioSoundStartResponder {
8534    control_handle: std::mem::ManuallyDrop<VirtioSoundControlHandle>,
8535    tx_id: u32,
8536}
8537
8538/// Set the the channel to be shutdown (see [`VirtioSoundControlHandle::shutdown`])
8539/// if the responder is dropped without sending a response, so that the client
8540/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8541impl std::ops::Drop for VirtioSoundStartResponder {
8542    fn drop(&mut self) {
8543        self.control_handle.shutdown();
8544        // Safety: drops once, never accessed again
8545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8546    }
8547}
8548
8549impl fidl::endpoints::Responder for VirtioSoundStartResponder {
8550    type ControlHandle = VirtioSoundControlHandle;
8551
8552    fn control_handle(&self) -> &VirtioSoundControlHandle {
8553        &self.control_handle
8554    }
8555
8556    fn drop_without_shutdown(mut self) {
8557        // Safety: drops once, never accessed again due to mem::forget
8558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8559        // Prevent Drop from running (which would shut down the channel)
8560        std::mem::forget(self);
8561    }
8562}
8563
8564impl VirtioSoundStartResponder {
8565    /// Sends a response to the FIDL transaction.
8566    ///
8567    /// Sets the channel to shutdown if an error occurs.
8568    pub fn send(
8569        self,
8570        mut features: u32,
8571        mut jacks: u32,
8572        mut streams: u32,
8573        mut chmaps: u32,
8574    ) -> Result<(), fidl::Error> {
8575        let _result = self.send_raw(features, jacks, streams, chmaps);
8576        if _result.is_err() {
8577            self.control_handle.shutdown();
8578        }
8579        self.drop_without_shutdown();
8580        _result
8581    }
8582
8583    /// Similar to "send" but does not shutdown the channel if an error occurs.
8584    pub fn send_no_shutdown_on_err(
8585        self,
8586        mut features: u32,
8587        mut jacks: u32,
8588        mut streams: u32,
8589        mut chmaps: u32,
8590    ) -> Result<(), fidl::Error> {
8591        let _result = self.send_raw(features, jacks, streams, chmaps);
8592        self.drop_without_shutdown();
8593        _result
8594    }
8595
8596    fn send_raw(
8597        &self,
8598        mut features: u32,
8599        mut jacks: u32,
8600        mut streams: u32,
8601        mut chmaps: u32,
8602    ) -> Result<(), fidl::Error> {
8603        self.control_handle.inner.send::<VirtioSoundStartResponse>(
8604            (features, jacks, streams, chmaps),
8605            self.tx_id,
8606            0x2c3a5528c0b92e2d,
8607            fidl::encoding::DynamicFlags::empty(),
8608        )
8609    }
8610}
8611
8612#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8613pub struct VirtioVsockMarker;
8614
8615impl fidl::endpoints::ProtocolMarker for VirtioVsockMarker {
8616    type Proxy = VirtioVsockProxy;
8617    type RequestStream = VirtioVsockRequestStream;
8618    #[cfg(target_os = "fuchsia")]
8619    type SynchronousProxy = VirtioVsockSynchronousProxy;
8620
8621    const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioVsock";
8622}
8623impl fidl::endpoints::DiscoverableProtocolMarker for VirtioVsockMarker {}
8624pub type VirtioVsockStartResult = Result<(), i32>;
8625
8626pub trait VirtioVsockProxyInterface: Send + Sync {
8627    type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8628    fn r#configure_queue(
8629        &self,
8630        queue: u16,
8631        size: u16,
8632        desc: u64,
8633        avail: u64,
8634        used: u64,
8635    ) -> Self::ConfigureQueueResponseFut;
8636    fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
8637    type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8638    fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
8639    type StartResponseFut: std::future::Future<Output = Result<VirtioVsockStartResult, fidl::Error>>
8640        + Send;
8641    fn r#start(
8642        &self,
8643        start_info: StartInfo,
8644        guest_cid: u32,
8645        listeners: Vec<fidl_fuchsia_virtualization::Listener>,
8646    ) -> Self::StartResponseFut;
8647}
8648#[derive(Debug)]
8649#[cfg(target_os = "fuchsia")]
8650pub struct VirtioVsockSynchronousProxy {
8651    client: fidl::client::sync::Client,
8652}
8653
8654#[cfg(target_os = "fuchsia")]
8655impl fidl::endpoints::SynchronousProxy for VirtioVsockSynchronousProxy {
8656    type Proxy = VirtioVsockProxy;
8657    type Protocol = VirtioVsockMarker;
8658
8659    fn from_channel(inner: fidl::Channel) -> Self {
8660        Self::new(inner)
8661    }
8662
8663    fn into_channel(self) -> fidl::Channel {
8664        self.client.into_channel()
8665    }
8666
8667    fn as_channel(&self) -> &fidl::Channel {
8668        self.client.as_channel()
8669    }
8670}
8671
8672#[cfg(target_os = "fuchsia")]
8673impl VirtioVsockSynchronousProxy {
8674    pub fn new(channel: fidl::Channel) -> Self {
8675        Self { client: fidl::client::sync::Client::new(channel) }
8676    }
8677
8678    pub fn into_channel(self) -> fidl::Channel {
8679        self.client.into_channel()
8680    }
8681
8682    /// Waits until an event arrives and returns it. It is safe for other
8683    /// threads to make concurrent requests while waiting for an event.
8684    pub fn wait_for_event(
8685        &self,
8686        deadline: zx::MonotonicInstant,
8687    ) -> Result<VirtioVsockEvent, fidl::Error> {
8688        VirtioVsockEvent::decode(self.client.wait_for_event::<VirtioVsockMarker>(deadline)?)
8689    }
8690
8691    /// Configure a `queue` for the device. This specifies the `size` and the
8692    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8693    pub fn r#configure_queue(
8694        &self,
8695        mut queue: u16,
8696        mut size: u16,
8697        mut desc: u64,
8698        mut avail: u64,
8699        mut used: u64,
8700        ___deadline: zx::MonotonicInstant,
8701    ) -> Result<(), fidl::Error> {
8702        let _response = self.client.send_query::<
8703            VirtioDeviceConfigureQueueRequest,
8704            fidl::encoding::EmptyPayload,
8705            VirtioVsockMarker,
8706        >(
8707            (queue, size, desc, avail, used,),
8708            0x72b44fb963480b11,
8709            fidl::encoding::DynamicFlags::empty(),
8710            ___deadline,
8711        )?;
8712        Ok(_response)
8713    }
8714
8715    /// Notify a `queue` for the device. Primarily used for black-box testing.
8716    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8717        self.client.send::<VirtioDeviceNotifyQueueRequest>(
8718            (queue,),
8719            0x6e3a61d652499244,
8720            fidl::encoding::DynamicFlags::empty(),
8721        )
8722    }
8723
8724    /// Ready a device. This provides the set of `negotiated_features` that the
8725    /// driver and device have agreed upon.
8726    pub fn r#ready(
8727        &self,
8728        mut negotiated_features: u32,
8729        ___deadline: zx::MonotonicInstant,
8730    ) -> Result<(), fidl::Error> {
8731        let _response = self.client.send_query::<
8732            VirtioDeviceReadyRequest,
8733            fidl::encoding::EmptyPayload,
8734            VirtioVsockMarker,
8735        >(
8736            (negotiated_features,),
8737            0x45707654f5d23c3f,
8738            fidl::encoding::DynamicFlags::empty(),
8739            ___deadline,
8740        )?;
8741        Ok(_response)
8742    }
8743
8744    /// Start the vsock device, setting the guest_cid to the provided value.
8745    ///
8746    /// Returns:
8747    ///   - ZX_OK if device startup succeeded
8748    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
8749    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
8750    pub fn r#start(
8751        &self,
8752        mut start_info: StartInfo,
8753        mut guest_cid: u32,
8754        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
8755        ___deadline: zx::MonotonicInstant,
8756    ) -> Result<VirtioVsockStartResult, fidl::Error> {
8757        let _response = self.client.send_query::<
8758            VirtioVsockStartRequest,
8759            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8760            VirtioVsockMarker,
8761        >(
8762            (&mut start_info, guest_cid, listeners.as_mut(),),
8763            0x56433562cf67ae0f,
8764            fidl::encoding::DynamicFlags::empty(),
8765            ___deadline,
8766        )?;
8767        Ok(_response.map(|x| x))
8768    }
8769}
8770
8771#[cfg(target_os = "fuchsia")]
8772impl From<VirtioVsockSynchronousProxy> for zx::NullableHandle {
8773    fn from(value: VirtioVsockSynchronousProxy) -> Self {
8774        value.into_channel().into()
8775    }
8776}
8777
8778#[cfg(target_os = "fuchsia")]
8779impl From<fidl::Channel> for VirtioVsockSynchronousProxy {
8780    fn from(value: fidl::Channel) -> Self {
8781        Self::new(value)
8782    }
8783}
8784
8785#[cfg(target_os = "fuchsia")]
8786impl fidl::endpoints::FromClient for VirtioVsockSynchronousProxy {
8787    type Protocol = VirtioVsockMarker;
8788
8789    fn from_client(value: fidl::endpoints::ClientEnd<VirtioVsockMarker>) -> Self {
8790        Self::new(value.into_channel())
8791    }
8792}
8793
8794#[derive(Debug, Clone)]
8795pub struct VirtioVsockProxy {
8796    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8797}
8798
8799impl fidl::endpoints::Proxy for VirtioVsockProxy {
8800    type Protocol = VirtioVsockMarker;
8801
8802    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8803        Self::new(inner)
8804    }
8805
8806    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8807        self.client.into_channel().map_err(|client| Self { client })
8808    }
8809
8810    fn as_channel(&self) -> &::fidl::AsyncChannel {
8811        self.client.as_channel()
8812    }
8813}
8814
8815impl VirtioVsockProxy {
8816    /// Create a new Proxy for fuchsia.virtualization.hardware/VirtioVsock.
8817    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8818        let protocol_name = <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8819        Self { client: fidl::client::Client::new(channel, protocol_name) }
8820    }
8821
8822    /// Get a Stream of events from the remote end of the protocol.
8823    ///
8824    /// # Panics
8825    ///
8826    /// Panics if the event stream was already taken.
8827    pub fn take_event_stream(&self) -> VirtioVsockEventStream {
8828        VirtioVsockEventStream { event_receiver: self.client.take_event_receiver() }
8829    }
8830
8831    /// Configure a `queue` for the device. This specifies the `size` and the
8832    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
8833    pub fn r#configure_queue(
8834        &self,
8835        mut queue: u16,
8836        mut size: u16,
8837        mut desc: u64,
8838        mut avail: u64,
8839        mut used: u64,
8840    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8841        VirtioVsockProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
8842    }
8843
8844    /// Notify a `queue` for the device. Primarily used for black-box testing.
8845    pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8846        VirtioVsockProxyInterface::r#notify_queue(self, queue)
8847    }
8848
8849    /// Ready a device. This provides the set of `negotiated_features` that the
8850    /// driver and device have agreed upon.
8851    pub fn r#ready(
8852        &self,
8853        mut negotiated_features: u32,
8854    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8855        VirtioVsockProxyInterface::r#ready(self, negotiated_features)
8856    }
8857
8858    /// Start the vsock device, setting the guest_cid to the provided value.
8859    ///
8860    /// Returns:
8861    ///   - ZX_OK if device startup succeeded
8862    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
8863    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
8864    pub fn r#start(
8865        &self,
8866        mut start_info: StartInfo,
8867        mut guest_cid: u32,
8868        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
8869    ) -> fidl::client::QueryResponseFut<
8870        VirtioVsockStartResult,
8871        fidl::encoding::DefaultFuchsiaResourceDialect,
8872    > {
8873        VirtioVsockProxyInterface::r#start(self, start_info, guest_cid, listeners)
8874    }
8875}
8876
8877impl VirtioVsockProxyInterface for VirtioVsockProxy {
8878    type ConfigureQueueResponseFut =
8879        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8880    fn r#configure_queue(
8881        &self,
8882        mut queue: u16,
8883        mut size: u16,
8884        mut desc: u64,
8885        mut avail: u64,
8886        mut used: u64,
8887    ) -> Self::ConfigureQueueResponseFut {
8888        fn _decode(
8889            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8890        ) -> Result<(), fidl::Error> {
8891            let _response = fidl::client::decode_transaction_body::<
8892                fidl::encoding::EmptyPayload,
8893                fidl::encoding::DefaultFuchsiaResourceDialect,
8894                0x72b44fb963480b11,
8895            >(_buf?)?;
8896            Ok(_response)
8897        }
8898        self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
8899            (queue, size, desc, avail, used),
8900            0x72b44fb963480b11,
8901            fidl::encoding::DynamicFlags::empty(),
8902            _decode,
8903        )
8904    }
8905
8906    fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
8907        self.client.send::<VirtioDeviceNotifyQueueRequest>(
8908            (queue,),
8909            0x6e3a61d652499244,
8910            fidl::encoding::DynamicFlags::empty(),
8911        )
8912    }
8913
8914    type ReadyResponseFut =
8915        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8916    fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
8917        fn _decode(
8918            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8919        ) -> Result<(), fidl::Error> {
8920            let _response = fidl::client::decode_transaction_body::<
8921                fidl::encoding::EmptyPayload,
8922                fidl::encoding::DefaultFuchsiaResourceDialect,
8923                0x45707654f5d23c3f,
8924            >(_buf?)?;
8925            Ok(_response)
8926        }
8927        self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
8928            (negotiated_features,),
8929            0x45707654f5d23c3f,
8930            fidl::encoding::DynamicFlags::empty(),
8931            _decode,
8932        )
8933    }
8934
8935    type StartResponseFut = fidl::client::QueryResponseFut<
8936        VirtioVsockStartResult,
8937        fidl::encoding::DefaultFuchsiaResourceDialect,
8938    >;
8939    fn r#start(
8940        &self,
8941        mut start_info: StartInfo,
8942        mut guest_cid: u32,
8943        mut listeners: Vec<fidl_fuchsia_virtualization::Listener>,
8944    ) -> Self::StartResponseFut {
8945        fn _decode(
8946            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8947        ) -> Result<VirtioVsockStartResult, fidl::Error> {
8948            let _response = fidl::client::decode_transaction_body::<
8949                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8950                fidl::encoding::DefaultFuchsiaResourceDialect,
8951                0x56433562cf67ae0f,
8952            >(_buf?)?;
8953            Ok(_response.map(|x| x))
8954        }
8955        self.client.send_query_and_decode::<VirtioVsockStartRequest, VirtioVsockStartResult>(
8956            (&mut start_info, guest_cid, listeners.as_mut()),
8957            0x56433562cf67ae0f,
8958            fidl::encoding::DynamicFlags::empty(),
8959            _decode,
8960        )
8961    }
8962}
8963
8964pub struct VirtioVsockEventStream {
8965    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8966}
8967
8968impl std::marker::Unpin for VirtioVsockEventStream {}
8969
8970impl futures::stream::FusedStream for VirtioVsockEventStream {
8971    fn is_terminated(&self) -> bool {
8972        self.event_receiver.is_terminated()
8973    }
8974}
8975
8976impl futures::Stream for VirtioVsockEventStream {
8977    type Item = Result<VirtioVsockEvent, fidl::Error>;
8978
8979    fn poll_next(
8980        mut self: std::pin::Pin<&mut Self>,
8981        cx: &mut std::task::Context<'_>,
8982    ) -> std::task::Poll<Option<Self::Item>> {
8983        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8984            &mut self.event_receiver,
8985            cx
8986        )?) {
8987            Some(buf) => std::task::Poll::Ready(Some(VirtioVsockEvent::decode(buf))),
8988            None => std::task::Poll::Ready(None),
8989        }
8990    }
8991}
8992
8993#[derive(Debug)]
8994pub enum VirtioVsockEvent {}
8995
8996impl VirtioVsockEvent {
8997    /// Decodes a message buffer as a [`VirtioVsockEvent`].
8998    fn decode(
8999        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9000    ) -> Result<VirtioVsockEvent, fidl::Error> {
9001        let (bytes, _handles) = buf.split_mut();
9002        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9003        debug_assert_eq!(tx_header.tx_id, 0);
9004        match tx_header.ordinal {
9005            _ => Err(fidl::Error::UnknownOrdinal {
9006                ordinal: tx_header.ordinal,
9007                protocol_name: <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9008            }),
9009        }
9010    }
9011}
9012
9013/// A Stream of incoming requests for fuchsia.virtualization.hardware/VirtioVsock.
9014pub struct VirtioVsockRequestStream {
9015    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9016    is_terminated: bool,
9017}
9018
9019impl std::marker::Unpin for VirtioVsockRequestStream {}
9020
9021impl futures::stream::FusedStream for VirtioVsockRequestStream {
9022    fn is_terminated(&self) -> bool {
9023        self.is_terminated
9024    }
9025}
9026
9027impl fidl::endpoints::RequestStream for VirtioVsockRequestStream {
9028    type Protocol = VirtioVsockMarker;
9029    type ControlHandle = VirtioVsockControlHandle;
9030
9031    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9032        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9033    }
9034
9035    fn control_handle(&self) -> Self::ControlHandle {
9036        VirtioVsockControlHandle { inner: self.inner.clone() }
9037    }
9038
9039    fn into_inner(
9040        self,
9041    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9042    {
9043        (self.inner, self.is_terminated)
9044    }
9045
9046    fn from_inner(
9047        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9048        is_terminated: bool,
9049    ) -> Self {
9050        Self { inner, is_terminated }
9051    }
9052}
9053
9054impl futures::Stream for VirtioVsockRequestStream {
9055    type Item = Result<VirtioVsockRequest, fidl::Error>;
9056
9057    fn poll_next(
9058        mut self: std::pin::Pin<&mut Self>,
9059        cx: &mut std::task::Context<'_>,
9060    ) -> std::task::Poll<Option<Self::Item>> {
9061        let this = &mut *self;
9062        if this.inner.check_shutdown(cx) {
9063            this.is_terminated = true;
9064            return std::task::Poll::Ready(None);
9065        }
9066        if this.is_terminated {
9067            panic!("polled VirtioVsockRequestStream after completion");
9068        }
9069        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9070            |bytes, handles| {
9071                match this.inner.channel().read_etc(cx, bytes, handles) {
9072                    std::task::Poll::Ready(Ok(())) => {}
9073                    std::task::Poll::Pending => return std::task::Poll::Pending,
9074                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9075                        this.is_terminated = true;
9076                        return std::task::Poll::Ready(None);
9077                    }
9078                    std::task::Poll::Ready(Err(e)) => {
9079                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9080                            e.into(),
9081                        ))));
9082                    }
9083                }
9084
9085                // A message has been received from the channel
9086                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9087
9088                std::task::Poll::Ready(Some(match header.ordinal {
9089                    0x72b44fb963480b11 => {
9090                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9091                        let mut req = fidl::new_empty!(
9092                            VirtioDeviceConfigureQueueRequest,
9093                            fidl::encoding::DefaultFuchsiaResourceDialect
9094                        );
9095                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
9096                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9097                        Ok(VirtioVsockRequest::ConfigureQueue {
9098                            queue: req.queue,
9099                            size: req.size,
9100                            desc: req.desc,
9101                            avail: req.avail,
9102                            used: req.used,
9103
9104                            responder: VirtioVsockConfigureQueueResponder {
9105                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9106                                tx_id: header.tx_id,
9107                            },
9108                        })
9109                    }
9110                    0x6e3a61d652499244 => {
9111                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9112                        let mut req = fidl::new_empty!(
9113                            VirtioDeviceNotifyQueueRequest,
9114                            fidl::encoding::DefaultFuchsiaResourceDialect
9115                        );
9116                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
9117                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9118                        Ok(VirtioVsockRequest::NotifyQueue { queue: req.queue, control_handle })
9119                    }
9120                    0x45707654f5d23c3f => {
9121                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9122                        let mut req = fidl::new_empty!(
9123                            VirtioDeviceReadyRequest,
9124                            fidl::encoding::DefaultFuchsiaResourceDialect
9125                        );
9126                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
9127                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9128                        Ok(VirtioVsockRequest::Ready {
9129                            negotiated_features: req.negotiated_features,
9130
9131                            responder: VirtioVsockReadyResponder {
9132                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9133                                tx_id: header.tx_id,
9134                            },
9135                        })
9136                    }
9137                    0x56433562cf67ae0f => {
9138                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9139                        let mut req = fidl::new_empty!(
9140                            VirtioVsockStartRequest,
9141                            fidl::encoding::DefaultFuchsiaResourceDialect
9142                        );
9143                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioVsockStartRequest>(&header, _body_bytes, handles, &mut req)?;
9144                        let control_handle = VirtioVsockControlHandle { inner: this.inner.clone() };
9145                        Ok(VirtioVsockRequest::Start {
9146                            start_info: req.start_info,
9147                            guest_cid: req.guest_cid,
9148                            listeners: req.listeners,
9149
9150                            responder: VirtioVsockStartResponder {
9151                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9152                                tx_id: header.tx_id,
9153                            },
9154                        })
9155                    }
9156                    _ => Err(fidl::Error::UnknownOrdinal {
9157                        ordinal: header.ordinal,
9158                        protocol_name:
9159                            <VirtioVsockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9160                    }),
9161                }))
9162            },
9163        )
9164    }
9165}
9166
9167#[derive(Debug)]
9168pub enum VirtioVsockRequest {
9169    /// Configure a `queue` for the device. This specifies the `size` and the
9170    /// guest physical addresses of the queue: `desc`, `avail`, and `used`.
9171    ConfigureQueue {
9172        queue: u16,
9173        size: u16,
9174        desc: u64,
9175        avail: u64,
9176        used: u64,
9177        responder: VirtioVsockConfigureQueueResponder,
9178    },
9179    /// Notify a `queue` for the device. Primarily used for black-box testing.
9180    NotifyQueue { queue: u16, control_handle: VirtioVsockControlHandle },
9181    /// Ready a device. This provides the set of `negotiated_features` that the
9182    /// driver and device have agreed upon.
9183    Ready { negotiated_features: u32, responder: VirtioVsockReadyResponder },
9184    /// Start the vsock device, setting the guest_cid to the provided value.
9185    ///
9186    /// Returns:
9187    ///   - ZX_OK if device startup succeeded
9188    ///   - ZX_ERR_INVALID_ARGS if guest_cid is a reserved value
9189    ///   - Any errors returned from fuchsia.virtualization.HostVsockEndpoint::Listen
9190    Start {
9191        start_info: StartInfo,
9192        guest_cid: u32,
9193        listeners: Vec<fidl_fuchsia_virtualization::Listener>,
9194        responder: VirtioVsockStartResponder,
9195    },
9196}
9197
9198impl VirtioVsockRequest {
9199    #[allow(irrefutable_let_patterns)]
9200    pub fn into_configure_queue(
9201        self,
9202    ) -> Option<(u16, u16, u64, u64, u64, VirtioVsockConfigureQueueResponder)> {
9203        if let VirtioVsockRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
9204            self
9205        {
9206            Some((queue, size, desc, avail, used, responder))
9207        } else {
9208            None
9209        }
9210    }
9211
9212    #[allow(irrefutable_let_patterns)]
9213    pub fn into_notify_queue(self) -> Option<(u16, VirtioVsockControlHandle)> {
9214        if let VirtioVsockRequest::NotifyQueue { queue, control_handle } = self {
9215            Some((queue, control_handle))
9216        } else {
9217            None
9218        }
9219    }
9220
9221    #[allow(irrefutable_let_patterns)]
9222    pub fn into_ready(self) -> Option<(u32, VirtioVsockReadyResponder)> {
9223        if let VirtioVsockRequest::Ready { negotiated_features, responder } = self {
9224            Some((negotiated_features, responder))
9225        } else {
9226            None
9227        }
9228    }
9229
9230    #[allow(irrefutable_let_patterns)]
9231    pub fn into_start(
9232        self,
9233    ) -> Option<(
9234        StartInfo,
9235        u32,
9236        Vec<fidl_fuchsia_virtualization::Listener>,
9237        VirtioVsockStartResponder,
9238    )> {
9239        if let VirtioVsockRequest::Start { start_info, guest_cid, listeners, responder } = self {
9240            Some((start_info, guest_cid, listeners, responder))
9241        } else {
9242            None
9243        }
9244    }
9245
9246    /// Name of the method defined in FIDL
9247    pub fn method_name(&self) -> &'static str {
9248        match *self {
9249            VirtioVsockRequest::ConfigureQueue { .. } => "configure_queue",
9250            VirtioVsockRequest::NotifyQueue { .. } => "notify_queue",
9251            VirtioVsockRequest::Ready { .. } => "ready",
9252            VirtioVsockRequest::Start { .. } => "start",
9253        }
9254    }
9255}
9256
9257#[derive(Debug, Clone)]
9258pub struct VirtioVsockControlHandle {
9259    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9260}
9261
9262impl fidl::endpoints::ControlHandle for VirtioVsockControlHandle {
9263    fn shutdown(&self) {
9264        self.inner.shutdown()
9265    }
9266
9267    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9268        self.inner.shutdown_with_epitaph(status)
9269    }
9270
9271    fn is_closed(&self) -> bool {
9272        self.inner.channel().is_closed()
9273    }
9274    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9275        self.inner.channel().on_closed()
9276    }
9277
9278    #[cfg(target_os = "fuchsia")]
9279    fn signal_peer(
9280        &self,
9281        clear_mask: zx::Signals,
9282        set_mask: zx::Signals,
9283    ) -> Result<(), zx_status::Status> {
9284        use fidl::Peered;
9285        self.inner.channel().signal_peer(clear_mask, set_mask)
9286    }
9287}
9288
9289impl VirtioVsockControlHandle {}
9290
9291#[must_use = "FIDL methods require a response to be sent"]
9292#[derive(Debug)]
9293pub struct VirtioVsockConfigureQueueResponder {
9294    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
9295    tx_id: u32,
9296}
9297
9298/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
9299/// if the responder is dropped without sending a response, so that the client
9300/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9301impl std::ops::Drop for VirtioVsockConfigureQueueResponder {
9302    fn drop(&mut self) {
9303        self.control_handle.shutdown();
9304        // Safety: drops once, never accessed again
9305        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9306    }
9307}
9308
9309impl fidl::endpoints::Responder for VirtioVsockConfigureQueueResponder {
9310    type ControlHandle = VirtioVsockControlHandle;
9311
9312    fn control_handle(&self) -> &VirtioVsockControlHandle {
9313        &self.control_handle
9314    }
9315
9316    fn drop_without_shutdown(mut self) {
9317        // Safety: drops once, never accessed again due to mem::forget
9318        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9319        // Prevent Drop from running (which would shut down the channel)
9320        std::mem::forget(self);
9321    }
9322}
9323
9324impl VirtioVsockConfigureQueueResponder {
9325    /// Sends a response to the FIDL transaction.
9326    ///
9327    /// Sets the channel to shutdown if an error occurs.
9328    pub fn send(self) -> Result<(), fidl::Error> {
9329        let _result = self.send_raw();
9330        if _result.is_err() {
9331            self.control_handle.shutdown();
9332        }
9333        self.drop_without_shutdown();
9334        _result
9335    }
9336
9337    /// Similar to "send" but does not shutdown the channel if an error occurs.
9338    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9339        let _result = self.send_raw();
9340        self.drop_without_shutdown();
9341        _result
9342    }
9343
9344    fn send_raw(&self) -> Result<(), fidl::Error> {
9345        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9346            (),
9347            self.tx_id,
9348            0x72b44fb963480b11,
9349            fidl::encoding::DynamicFlags::empty(),
9350        )
9351    }
9352}
9353
9354#[must_use = "FIDL methods require a response to be sent"]
9355#[derive(Debug)]
9356pub struct VirtioVsockReadyResponder {
9357    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
9358    tx_id: u32,
9359}
9360
9361/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
9362/// if the responder is dropped without sending a response, so that the client
9363/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9364impl std::ops::Drop for VirtioVsockReadyResponder {
9365    fn drop(&mut self) {
9366        self.control_handle.shutdown();
9367        // Safety: drops once, never accessed again
9368        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9369    }
9370}
9371
9372impl fidl::endpoints::Responder for VirtioVsockReadyResponder {
9373    type ControlHandle = VirtioVsockControlHandle;
9374
9375    fn control_handle(&self) -> &VirtioVsockControlHandle {
9376        &self.control_handle
9377    }
9378
9379    fn drop_without_shutdown(mut self) {
9380        // Safety: drops once, never accessed again due to mem::forget
9381        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9382        // Prevent Drop from running (which would shut down the channel)
9383        std::mem::forget(self);
9384    }
9385}
9386
9387impl VirtioVsockReadyResponder {
9388    /// Sends a response to the FIDL transaction.
9389    ///
9390    /// Sets the channel to shutdown if an error occurs.
9391    pub fn send(self) -> Result<(), fidl::Error> {
9392        let _result = self.send_raw();
9393        if _result.is_err() {
9394            self.control_handle.shutdown();
9395        }
9396        self.drop_without_shutdown();
9397        _result
9398    }
9399
9400    /// Similar to "send" but does not shutdown the channel if an error occurs.
9401    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9402        let _result = self.send_raw();
9403        self.drop_without_shutdown();
9404        _result
9405    }
9406
9407    fn send_raw(&self) -> Result<(), fidl::Error> {
9408        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9409            (),
9410            self.tx_id,
9411            0x45707654f5d23c3f,
9412            fidl::encoding::DynamicFlags::empty(),
9413        )
9414    }
9415}
9416
9417#[must_use = "FIDL methods require a response to be sent"]
9418#[derive(Debug)]
9419pub struct VirtioVsockStartResponder {
9420    control_handle: std::mem::ManuallyDrop<VirtioVsockControlHandle>,
9421    tx_id: u32,
9422}
9423
9424/// Set the the channel to be shutdown (see [`VirtioVsockControlHandle::shutdown`])
9425/// if the responder is dropped without sending a response, so that the client
9426/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9427impl std::ops::Drop for VirtioVsockStartResponder {
9428    fn drop(&mut self) {
9429        self.control_handle.shutdown();
9430        // Safety: drops once, never accessed again
9431        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9432    }
9433}
9434
9435impl fidl::endpoints::Responder for VirtioVsockStartResponder {
9436    type ControlHandle = VirtioVsockControlHandle;
9437
9438    fn control_handle(&self) -> &VirtioVsockControlHandle {
9439        &self.control_handle
9440    }
9441
9442    fn drop_without_shutdown(mut self) {
9443        // Safety: drops once, never accessed again due to mem::forget
9444        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9445        // Prevent Drop from running (which would shut down the channel)
9446        std::mem::forget(self);
9447    }
9448}
9449
9450impl VirtioVsockStartResponder {
9451    /// Sends a response to the FIDL transaction.
9452    ///
9453    /// Sets the channel to shutdown if an error occurs.
9454    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9455        let _result = self.send_raw(result);
9456        if _result.is_err() {
9457            self.control_handle.shutdown();
9458        }
9459        self.drop_without_shutdown();
9460        _result
9461    }
9462
9463    /// Similar to "send" but does not shutdown the channel if an error occurs.
9464    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9465        let _result = self.send_raw(result);
9466        self.drop_without_shutdown();
9467        _result
9468    }
9469
9470    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9471        self.control_handle
9472            .inner
9473            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9474                result,
9475                self.tx_id,
9476                0x56433562cf67ae0f,
9477                fidl::encoding::DynamicFlags::empty(),
9478            )
9479    }
9480}
9481
9482mod internal {
9483    use super::*;
9484
9485    impl fidl::encoding::ResourceTypeMarker for StartInfo {
9486        type Borrowed<'a> = &'a mut Self;
9487        fn take_or_borrow<'a>(
9488            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9489        ) -> Self::Borrowed<'a> {
9490            value
9491        }
9492    }
9493
9494    unsafe impl fidl::encoding::TypeMarker for StartInfo {
9495        type Owned = Self;
9496
9497        #[inline(always)]
9498        fn inline_align(_context: fidl::encoding::Context) -> usize {
9499            8
9500        }
9501
9502        #[inline(always)]
9503        fn inline_size(_context: fidl::encoding::Context) -> usize {
9504            32
9505        }
9506    }
9507
9508    unsafe impl fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
9509        for &mut StartInfo
9510    {
9511        #[inline]
9512        unsafe fn encode(
9513            self,
9514            encoder: &mut fidl::encoding::Encoder<
9515                '_,
9516                fidl::encoding::DefaultFuchsiaResourceDialect,
9517            >,
9518            offset: usize,
9519            _depth: fidl::encoding::Depth,
9520        ) -> fidl::Result<()> {
9521            encoder.debug_check_bounds::<StartInfo>(offset);
9522            // Delegate to tuple encoding.
9523            fidl::encoding::Encode::<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9524                (
9525                    <Trap as fidl::encoding::ValueTypeMarker>::borrow(&self.trap),
9526                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Guest, { fidl::ObjectType::GUEST.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.guest),
9527                    <fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.event),
9528                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
9529                ),
9530                encoder, offset, _depth
9531            )
9532        }
9533    }
9534    unsafe impl<
9535        T0: fidl::encoding::Encode<Trap, fidl::encoding::DefaultFuchsiaResourceDialect>,
9536        T1: fidl::encoding::Encode<
9537                fidl::encoding::Optional<
9538                    fidl::encoding::HandleType<
9539                        fidl::Guest,
9540                        { fidl::ObjectType::GUEST.into_raw() },
9541                        2147483648,
9542                    >,
9543                >,
9544                fidl::encoding::DefaultFuchsiaResourceDialect,
9545            >,
9546        T2: fidl::encoding::Encode<
9547                fidl::encoding::HandleType<
9548                    fidl::Event,
9549                    { fidl::ObjectType::EVENT.into_raw() },
9550                    2147483648,
9551                >,
9552                fidl::encoding::DefaultFuchsiaResourceDialect,
9553            >,
9554        T3: fidl::encoding::Encode<
9555                fidl::encoding::HandleType<
9556                    fidl::Vmo,
9557                    { fidl::ObjectType::VMO.into_raw() },
9558                    2147483648,
9559                >,
9560                fidl::encoding::DefaultFuchsiaResourceDialect,
9561            >,
9562    > fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
9563        for (T0, T1, T2, T3)
9564    {
9565        #[inline]
9566        unsafe fn encode(
9567            self,
9568            encoder: &mut fidl::encoding::Encoder<
9569                '_,
9570                fidl::encoding::DefaultFuchsiaResourceDialect,
9571            >,
9572            offset: usize,
9573            depth: fidl::encoding::Depth,
9574        ) -> fidl::Result<()> {
9575            encoder.debug_check_bounds::<StartInfo>(offset);
9576            // Zero out padding regions. There's no need to apply masks
9577            // because the unmasked parts will be overwritten by fields.
9578            unsafe {
9579                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
9580                (ptr as *mut u64).write_unaligned(0);
9581            }
9582            // Write the fields.
9583            self.0.encode(encoder, offset + 0, depth)?;
9584            self.1.encode(encoder, offset + 16, depth)?;
9585            self.2.encode(encoder, offset + 20, depth)?;
9586            self.3.encode(encoder, offset + 24, depth)?;
9587            Ok(())
9588        }
9589    }
9590
9591    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for StartInfo {
9592        #[inline(always)]
9593        fn new_empty() -> Self {
9594            Self {
9595                trap: fidl::new_empty!(Trap, fidl::encoding::DefaultFuchsiaResourceDialect),
9596                guest: fidl::new_empty!(
9597                    fidl::encoding::Optional<
9598                        fidl::encoding::HandleType<
9599                            fidl::Guest,
9600                            { fidl::ObjectType::GUEST.into_raw() },
9601                            2147483648,
9602                        >,
9603                    >,
9604                    fidl::encoding::DefaultFuchsiaResourceDialect
9605                ),
9606                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9607                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9608            }
9609        }
9610
9611        #[inline]
9612        unsafe fn decode(
9613            &mut self,
9614            decoder: &mut fidl::encoding::Decoder<
9615                '_,
9616                fidl::encoding::DefaultFuchsiaResourceDialect,
9617            >,
9618            offset: usize,
9619            _depth: fidl::encoding::Depth,
9620        ) -> fidl::Result<()> {
9621            decoder.debug_check_bounds::<Self>(offset);
9622            // Verify that padding bytes are zero.
9623            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
9624            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9625            let mask = 0xffffffff00000000u64;
9626            let maskedval = padval & mask;
9627            if maskedval != 0 {
9628                return Err(fidl::Error::NonZeroPadding {
9629                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
9630                });
9631            }
9632            fidl::decode!(
9633                Trap,
9634                fidl::encoding::DefaultFuchsiaResourceDialect,
9635                &mut self.trap,
9636                decoder,
9637                offset + 0,
9638                _depth
9639            )?;
9640            fidl::decode!(
9641                fidl::encoding::Optional<
9642                    fidl::encoding::HandleType<
9643                        fidl::Guest,
9644                        { fidl::ObjectType::GUEST.into_raw() },
9645                        2147483648,
9646                    >,
9647                >,
9648                fidl::encoding::DefaultFuchsiaResourceDialect,
9649                &mut self.guest,
9650                decoder,
9651                offset + 16,
9652                _depth
9653            )?;
9654            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 20, _depth)?;
9655            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 24, _depth)?;
9656            Ok(())
9657        }
9658    }
9659
9660    impl fidl::encoding::ResourceTypeMarker for VirtioBalloonStartRequest {
9661        type Borrowed<'a> = &'a mut Self;
9662        fn take_or_borrow<'a>(
9663            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9664        ) -> Self::Borrowed<'a> {
9665            value
9666        }
9667    }
9668
9669    unsafe impl fidl::encoding::TypeMarker for VirtioBalloonStartRequest {
9670        type Owned = Self;
9671
9672        #[inline(always)]
9673        fn inline_align(_context: fidl::encoding::Context) -> usize {
9674            8
9675        }
9676
9677        #[inline(always)]
9678        fn inline_size(_context: fidl::encoding::Context) -> usize {
9679            32
9680        }
9681    }
9682
9683    unsafe impl
9684        fidl::encoding::Encode<
9685            VirtioBalloonStartRequest,
9686            fidl::encoding::DefaultFuchsiaResourceDialect,
9687        > for &mut VirtioBalloonStartRequest
9688    {
9689        #[inline]
9690        unsafe fn encode(
9691            self,
9692            encoder: &mut fidl::encoding::Encoder<
9693                '_,
9694                fidl::encoding::DefaultFuchsiaResourceDialect,
9695            >,
9696            offset: usize,
9697            _depth: fidl::encoding::Depth,
9698        ) -> fidl::Result<()> {
9699            encoder.debug_check_bounds::<VirtioBalloonStartRequest>(offset);
9700            // Delegate to tuple encoding.
9701            fidl::encoding::Encode::<
9702                VirtioBalloonStartRequest,
9703                fidl::encoding::DefaultFuchsiaResourceDialect,
9704            >::encode(
9705                (<StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9706                    &mut self.start_info,
9707                ),),
9708                encoder,
9709                offset,
9710                _depth,
9711            )
9712        }
9713    }
9714    unsafe impl<
9715        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
9716    >
9717        fidl::encoding::Encode<
9718            VirtioBalloonStartRequest,
9719            fidl::encoding::DefaultFuchsiaResourceDialect,
9720        > for (T0,)
9721    {
9722        #[inline]
9723        unsafe fn encode(
9724            self,
9725            encoder: &mut fidl::encoding::Encoder<
9726                '_,
9727                fidl::encoding::DefaultFuchsiaResourceDialect,
9728            >,
9729            offset: usize,
9730            depth: fidl::encoding::Depth,
9731        ) -> fidl::Result<()> {
9732            encoder.debug_check_bounds::<VirtioBalloonStartRequest>(offset);
9733            // Zero out padding regions. There's no need to apply masks
9734            // because the unmasked parts will be overwritten by fields.
9735            // Write the fields.
9736            self.0.encode(encoder, offset + 0, depth)?;
9737            Ok(())
9738        }
9739    }
9740
9741    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9742        for VirtioBalloonStartRequest
9743    {
9744        #[inline(always)]
9745        fn new_empty() -> Self {
9746            Self {
9747                start_info: fidl::new_empty!(
9748                    StartInfo,
9749                    fidl::encoding::DefaultFuchsiaResourceDialect
9750                ),
9751            }
9752        }
9753
9754        #[inline]
9755        unsafe fn decode(
9756            &mut self,
9757            decoder: &mut fidl::encoding::Decoder<
9758                '_,
9759                fidl::encoding::DefaultFuchsiaResourceDialect,
9760            >,
9761            offset: usize,
9762            _depth: fidl::encoding::Depth,
9763        ) -> fidl::Result<()> {
9764            decoder.debug_check_bounds::<Self>(offset);
9765            // Verify that padding bytes are zero.
9766            fidl::decode!(
9767                StartInfo,
9768                fidl::encoding::DefaultFuchsiaResourceDialect,
9769                &mut self.start_info,
9770                decoder,
9771                offset + 0,
9772                _depth
9773            )?;
9774            Ok(())
9775        }
9776    }
9777
9778    impl fidl::encoding::ResourceTypeMarker for VirtioBlockStartRequest {
9779        type Borrowed<'a> = &'a mut Self;
9780        fn take_or_borrow<'a>(
9781            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9782        ) -> Self::Borrowed<'a> {
9783            value
9784        }
9785    }
9786
9787    unsafe impl fidl::encoding::TypeMarker for VirtioBlockStartRequest {
9788        type Owned = Self;
9789
9790        #[inline(always)]
9791        fn inline_align(_context: fidl::encoding::Context) -> usize {
9792            8
9793        }
9794
9795        #[inline(always)]
9796        fn inline_size(_context: fidl::encoding::Context) -> usize {
9797            72
9798        }
9799    }
9800
9801    unsafe impl
9802        fidl::encoding::Encode<
9803            VirtioBlockStartRequest,
9804            fidl::encoding::DefaultFuchsiaResourceDialect,
9805        > for &mut VirtioBlockStartRequest
9806    {
9807        #[inline]
9808        unsafe fn encode(
9809            self,
9810            encoder: &mut fidl::encoding::Encoder<
9811                '_,
9812                fidl::encoding::DefaultFuchsiaResourceDialect,
9813            >,
9814            offset: usize,
9815            _depth: fidl::encoding::Depth,
9816        ) -> fidl::Result<()> {
9817            encoder.debug_check_bounds::<VirtioBlockStartRequest>(offset);
9818            // Delegate to tuple encoding.
9819            fidl::encoding::Encode::<VirtioBlockStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9820                (
9821                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.start_info),
9822                    <fidl_fuchsia_virtualization::BlockSpec as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.spec),
9823                ),
9824                encoder, offset, _depth
9825            )
9826        }
9827    }
9828    unsafe impl<
9829        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
9830        T1: fidl::encoding::Encode<
9831                fidl_fuchsia_virtualization::BlockSpec,
9832                fidl::encoding::DefaultFuchsiaResourceDialect,
9833            >,
9834    >
9835        fidl::encoding::Encode<
9836            VirtioBlockStartRequest,
9837            fidl::encoding::DefaultFuchsiaResourceDialect,
9838        > for (T0, T1)
9839    {
9840        #[inline]
9841        unsafe fn encode(
9842            self,
9843            encoder: &mut fidl::encoding::Encoder<
9844                '_,
9845                fidl::encoding::DefaultFuchsiaResourceDialect,
9846            >,
9847            offset: usize,
9848            depth: fidl::encoding::Depth,
9849        ) -> fidl::Result<()> {
9850            encoder.debug_check_bounds::<VirtioBlockStartRequest>(offset);
9851            // Zero out padding regions. There's no need to apply masks
9852            // because the unmasked parts will be overwritten by fields.
9853            // Write the fields.
9854            self.0.encode(encoder, offset + 0, depth)?;
9855            self.1.encode(encoder, offset + 32, depth)?;
9856            Ok(())
9857        }
9858    }
9859
9860    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9861        for VirtioBlockStartRequest
9862    {
9863        #[inline(always)]
9864        fn new_empty() -> Self {
9865            Self {
9866                start_info: fidl::new_empty!(
9867                    StartInfo,
9868                    fidl::encoding::DefaultFuchsiaResourceDialect
9869                ),
9870                spec: fidl::new_empty!(
9871                    fidl_fuchsia_virtualization::BlockSpec,
9872                    fidl::encoding::DefaultFuchsiaResourceDialect
9873                ),
9874            }
9875        }
9876
9877        #[inline]
9878        unsafe fn decode(
9879            &mut self,
9880            decoder: &mut fidl::encoding::Decoder<
9881                '_,
9882                fidl::encoding::DefaultFuchsiaResourceDialect,
9883            >,
9884            offset: usize,
9885            _depth: fidl::encoding::Depth,
9886        ) -> fidl::Result<()> {
9887            decoder.debug_check_bounds::<Self>(offset);
9888            // Verify that padding bytes are zero.
9889            fidl::decode!(
9890                StartInfo,
9891                fidl::encoding::DefaultFuchsiaResourceDialect,
9892                &mut self.start_info,
9893                decoder,
9894                offset + 0,
9895                _depth
9896            )?;
9897            fidl::decode!(
9898                fidl_fuchsia_virtualization::BlockSpec,
9899                fidl::encoding::DefaultFuchsiaResourceDialect,
9900                &mut self.spec,
9901                decoder,
9902                offset + 32,
9903                _depth
9904            )?;
9905            Ok(())
9906        }
9907    }
9908
9909    impl fidl::encoding::ResourceTypeMarker for VirtioConsoleStartRequest {
9910        type Borrowed<'a> = &'a mut Self;
9911        fn take_or_borrow<'a>(
9912            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9913        ) -> Self::Borrowed<'a> {
9914            value
9915        }
9916    }
9917
9918    unsafe impl fidl::encoding::TypeMarker for VirtioConsoleStartRequest {
9919        type Owned = Self;
9920
9921        #[inline(always)]
9922        fn inline_align(_context: fidl::encoding::Context) -> usize {
9923            8
9924        }
9925
9926        #[inline(always)]
9927        fn inline_size(_context: fidl::encoding::Context) -> usize {
9928            40
9929        }
9930    }
9931
9932    unsafe impl
9933        fidl::encoding::Encode<
9934            VirtioConsoleStartRequest,
9935            fidl::encoding::DefaultFuchsiaResourceDialect,
9936        > for &mut VirtioConsoleStartRequest
9937    {
9938        #[inline]
9939        unsafe fn encode(
9940            self,
9941            encoder: &mut fidl::encoding::Encoder<
9942                '_,
9943                fidl::encoding::DefaultFuchsiaResourceDialect,
9944            >,
9945            offset: usize,
9946            _depth: fidl::encoding::Depth,
9947        ) -> fidl::Result<()> {
9948            encoder.debug_check_bounds::<VirtioConsoleStartRequest>(offset);
9949            // Delegate to tuple encoding.
9950            fidl::encoding::Encode::<
9951                VirtioConsoleStartRequest,
9952                fidl::encoding::DefaultFuchsiaResourceDialect,
9953            >::encode(
9954                (
9955                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9956                        &mut self.start_info,
9957                    ),
9958                    <fidl::encoding::HandleType<
9959                        fidl::Socket,
9960                        { fidl::ObjectType::SOCKET.into_raw() },
9961                        2147483648,
9962                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9963                        &mut self.socket
9964                    ),
9965                ),
9966                encoder,
9967                offset,
9968                _depth,
9969            )
9970        }
9971    }
9972    unsafe impl<
9973        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
9974        T1: fidl::encoding::Encode<
9975                fidl::encoding::HandleType<
9976                    fidl::Socket,
9977                    { fidl::ObjectType::SOCKET.into_raw() },
9978                    2147483648,
9979                >,
9980                fidl::encoding::DefaultFuchsiaResourceDialect,
9981            >,
9982    >
9983        fidl::encoding::Encode<
9984            VirtioConsoleStartRequest,
9985            fidl::encoding::DefaultFuchsiaResourceDialect,
9986        > for (T0, T1)
9987    {
9988        #[inline]
9989        unsafe fn encode(
9990            self,
9991            encoder: &mut fidl::encoding::Encoder<
9992                '_,
9993                fidl::encoding::DefaultFuchsiaResourceDialect,
9994            >,
9995            offset: usize,
9996            depth: fidl::encoding::Depth,
9997        ) -> fidl::Result<()> {
9998            encoder.debug_check_bounds::<VirtioConsoleStartRequest>(offset);
9999            // Zero out padding regions. There's no need to apply masks
10000            // because the unmasked parts will be overwritten by fields.
10001            unsafe {
10002                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
10003                (ptr as *mut u64).write_unaligned(0);
10004            }
10005            // Write the fields.
10006            self.0.encode(encoder, offset + 0, depth)?;
10007            self.1.encode(encoder, offset + 32, depth)?;
10008            Ok(())
10009        }
10010    }
10011
10012    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10013        for VirtioConsoleStartRequest
10014    {
10015        #[inline(always)]
10016        fn new_empty() -> Self {
10017            Self {
10018                start_info: fidl::new_empty!(
10019                    StartInfo,
10020                    fidl::encoding::DefaultFuchsiaResourceDialect
10021                ),
10022                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10023            }
10024        }
10025
10026        #[inline]
10027        unsafe fn decode(
10028            &mut self,
10029            decoder: &mut fidl::encoding::Decoder<
10030                '_,
10031                fidl::encoding::DefaultFuchsiaResourceDialect,
10032            >,
10033            offset: usize,
10034            _depth: fidl::encoding::Depth,
10035        ) -> fidl::Result<()> {
10036            decoder.debug_check_bounds::<Self>(offset);
10037            // Verify that padding bytes are zero.
10038            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
10039            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10040            let mask = 0xffffffff00000000u64;
10041            let maskedval = padval & mask;
10042            if maskedval != 0 {
10043                return Err(fidl::Error::NonZeroPadding {
10044                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
10045                });
10046            }
10047            fidl::decode!(
10048                StartInfo,
10049                fidl::encoding::DefaultFuchsiaResourceDialect,
10050                &mut self.start_info,
10051                decoder,
10052                offset + 0,
10053                _depth
10054            )?;
10055            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 32, _depth)?;
10056            Ok(())
10057        }
10058    }
10059
10060    impl fidl::encoding::ResourceTypeMarker for VirtioGpuStartRequest {
10061        type Borrowed<'a> = &'a mut Self;
10062        fn take_or_borrow<'a>(
10063            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10064        ) -> Self::Borrowed<'a> {
10065            value
10066        }
10067    }
10068
10069    unsafe impl fidl::encoding::TypeMarker for VirtioGpuStartRequest {
10070        type Owned = Self;
10071
10072        #[inline(always)]
10073        fn inline_align(_context: fidl::encoding::Context) -> usize {
10074            8
10075        }
10076
10077        #[inline(always)]
10078        fn inline_size(_context: fidl::encoding::Context) -> usize {
10079            40
10080        }
10081    }
10082
10083    unsafe impl
10084        fidl::encoding::Encode<VirtioGpuStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10085        for &mut VirtioGpuStartRequest
10086    {
10087        #[inline]
10088        unsafe fn encode(
10089            self,
10090            encoder: &mut fidl::encoding::Encoder<
10091                '_,
10092                fidl::encoding::DefaultFuchsiaResourceDialect,
10093            >,
10094            offset: usize,
10095            _depth: fidl::encoding::Depth,
10096        ) -> fidl::Result<()> {
10097            encoder.debug_check_bounds::<VirtioGpuStartRequest>(offset);
10098            // Delegate to tuple encoding.
10099            fidl::encoding::Encode::<
10100                VirtioGpuStartRequest,
10101                fidl::encoding::DefaultFuchsiaResourceDialect,
10102            >::encode(
10103                (
10104                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10105                        &mut self.start_info,
10106                    ),
10107                    <fidl::encoding::Optional<
10108                        fidl::encoding::Endpoint<
10109                            fidl::endpoints::ClientEnd<
10110                                fidl_fuchsia_ui_input3::KeyboardListenerMarker,
10111                            >,
10112                        >,
10113                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10114                        &mut self.keyboard_listener,
10115                    ),
10116                    <fidl::encoding::Optional<
10117                        fidl::encoding::Endpoint<
10118                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
10119                        >,
10120                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10121                        &mut self.mouse_source,
10122                    ),
10123                ),
10124                encoder,
10125                offset,
10126                _depth,
10127            )
10128        }
10129    }
10130    unsafe impl<
10131        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10132        T1: fidl::encoding::Encode<
10133                fidl::encoding::Optional<
10134                    fidl::encoding::Endpoint<
10135                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
10136                    >,
10137                >,
10138                fidl::encoding::DefaultFuchsiaResourceDialect,
10139            >,
10140        T2: fidl::encoding::Encode<
10141                fidl::encoding::Optional<
10142                    fidl::encoding::Endpoint<
10143                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
10144                    >,
10145                >,
10146                fidl::encoding::DefaultFuchsiaResourceDialect,
10147            >,
10148    >
10149        fidl::encoding::Encode<VirtioGpuStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10150        for (T0, T1, T2)
10151    {
10152        #[inline]
10153        unsafe fn encode(
10154            self,
10155            encoder: &mut fidl::encoding::Encoder<
10156                '_,
10157                fidl::encoding::DefaultFuchsiaResourceDialect,
10158            >,
10159            offset: usize,
10160            depth: fidl::encoding::Depth,
10161        ) -> fidl::Result<()> {
10162            encoder.debug_check_bounds::<VirtioGpuStartRequest>(offset);
10163            // Zero out padding regions. There's no need to apply masks
10164            // because the unmasked parts will be overwritten by fields.
10165            // Write the fields.
10166            self.0.encode(encoder, offset + 0, depth)?;
10167            self.1.encode(encoder, offset + 32, depth)?;
10168            self.2.encode(encoder, offset + 36, depth)?;
10169            Ok(())
10170        }
10171    }
10172
10173    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10174        for VirtioGpuStartRequest
10175    {
10176        #[inline(always)]
10177        fn new_empty() -> Self {
10178            Self {
10179                start_info: fidl::new_empty!(
10180                    StartInfo,
10181                    fidl::encoding::DefaultFuchsiaResourceDialect
10182                ),
10183                keyboard_listener: fidl::new_empty!(
10184                    fidl::encoding::Optional<
10185                        fidl::encoding::Endpoint<
10186                            fidl::endpoints::ClientEnd<
10187                                fidl_fuchsia_ui_input3::KeyboardListenerMarker,
10188                            >,
10189                        >,
10190                    >,
10191                    fidl::encoding::DefaultFuchsiaResourceDialect
10192                ),
10193                mouse_source: fidl::new_empty!(
10194                    fidl::encoding::Optional<
10195                        fidl::encoding::Endpoint<
10196                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
10197                        >,
10198                    >,
10199                    fidl::encoding::DefaultFuchsiaResourceDialect
10200                ),
10201            }
10202        }
10203
10204        #[inline]
10205        unsafe fn decode(
10206            &mut self,
10207            decoder: &mut fidl::encoding::Decoder<
10208                '_,
10209                fidl::encoding::DefaultFuchsiaResourceDialect,
10210            >,
10211            offset: usize,
10212            _depth: fidl::encoding::Depth,
10213        ) -> fidl::Result<()> {
10214            decoder.debug_check_bounds::<Self>(offset);
10215            // Verify that padding bytes are zero.
10216            fidl::decode!(
10217                StartInfo,
10218                fidl::encoding::DefaultFuchsiaResourceDialect,
10219                &mut self.start_info,
10220                decoder,
10221                offset + 0,
10222                _depth
10223            )?;
10224            fidl::decode!(
10225                fidl::encoding::Optional<
10226                    fidl::encoding::Endpoint<
10227                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
10228                    >,
10229                >,
10230                fidl::encoding::DefaultFuchsiaResourceDialect,
10231                &mut self.keyboard_listener,
10232                decoder,
10233                offset + 32,
10234                _depth
10235            )?;
10236            fidl::decode!(
10237                fidl::encoding::Optional<
10238                    fidl::encoding::Endpoint<
10239                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
10240                    >,
10241                >,
10242                fidl::encoding::DefaultFuchsiaResourceDialect,
10243                &mut self.mouse_source,
10244                decoder,
10245                offset + 36,
10246                _depth
10247            )?;
10248            Ok(())
10249        }
10250    }
10251
10252    impl fidl::encoding::ResourceTypeMarker for VirtioInputStartRequest {
10253        type Borrowed<'a> = &'a mut Self;
10254        fn take_or_borrow<'a>(
10255            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10256        ) -> Self::Borrowed<'a> {
10257            value
10258        }
10259    }
10260
10261    unsafe impl fidl::encoding::TypeMarker for VirtioInputStartRequest {
10262        type Owned = Self;
10263
10264        #[inline(always)]
10265        fn inline_align(_context: fidl::encoding::Context) -> usize {
10266            8
10267        }
10268
10269        #[inline(always)]
10270        fn inline_size(_context: fidl::encoding::Context) -> usize {
10271            48
10272        }
10273    }
10274
10275    unsafe impl
10276        fidl::encoding::Encode<
10277            VirtioInputStartRequest,
10278            fidl::encoding::DefaultFuchsiaResourceDialect,
10279        > for &mut VirtioInputStartRequest
10280    {
10281        #[inline]
10282        unsafe fn encode(
10283            self,
10284            encoder: &mut fidl::encoding::Encoder<
10285                '_,
10286                fidl::encoding::DefaultFuchsiaResourceDialect,
10287            >,
10288            offset: usize,
10289            _depth: fidl::encoding::Depth,
10290        ) -> fidl::Result<()> {
10291            encoder.debug_check_bounds::<VirtioInputStartRequest>(offset);
10292            // Delegate to tuple encoding.
10293            fidl::encoding::Encode::<
10294                VirtioInputStartRequest,
10295                fidl::encoding::DefaultFuchsiaResourceDialect,
10296            >::encode(
10297                (
10298                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10299                        &mut self.start_info,
10300                    ),
10301                    <InputType as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10302                        &mut self.input_type,
10303                    ),
10304                ),
10305                encoder,
10306                offset,
10307                _depth,
10308            )
10309        }
10310    }
10311    unsafe impl<
10312        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10313        T1: fidl::encoding::Encode<InputType, fidl::encoding::DefaultFuchsiaResourceDialect>,
10314    >
10315        fidl::encoding::Encode<
10316            VirtioInputStartRequest,
10317            fidl::encoding::DefaultFuchsiaResourceDialect,
10318        > for (T0, T1)
10319    {
10320        #[inline]
10321        unsafe fn encode(
10322            self,
10323            encoder: &mut fidl::encoding::Encoder<
10324                '_,
10325                fidl::encoding::DefaultFuchsiaResourceDialect,
10326            >,
10327            offset: usize,
10328            depth: fidl::encoding::Depth,
10329        ) -> fidl::Result<()> {
10330            encoder.debug_check_bounds::<VirtioInputStartRequest>(offset);
10331            // Zero out padding regions. There's no need to apply masks
10332            // because the unmasked parts will be overwritten by fields.
10333            // Write the fields.
10334            self.0.encode(encoder, offset + 0, depth)?;
10335            self.1.encode(encoder, offset + 32, depth)?;
10336            Ok(())
10337        }
10338    }
10339
10340    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10341        for VirtioInputStartRequest
10342    {
10343        #[inline(always)]
10344        fn new_empty() -> Self {
10345            Self {
10346                start_info: fidl::new_empty!(
10347                    StartInfo,
10348                    fidl::encoding::DefaultFuchsiaResourceDialect
10349                ),
10350                input_type: fidl::new_empty!(
10351                    InputType,
10352                    fidl::encoding::DefaultFuchsiaResourceDialect
10353                ),
10354            }
10355        }
10356
10357        #[inline]
10358        unsafe fn decode(
10359            &mut self,
10360            decoder: &mut fidl::encoding::Decoder<
10361                '_,
10362                fidl::encoding::DefaultFuchsiaResourceDialect,
10363            >,
10364            offset: usize,
10365            _depth: fidl::encoding::Depth,
10366        ) -> fidl::Result<()> {
10367            decoder.debug_check_bounds::<Self>(offset);
10368            // Verify that padding bytes are zero.
10369            fidl::decode!(
10370                StartInfo,
10371                fidl::encoding::DefaultFuchsiaResourceDialect,
10372                &mut self.start_info,
10373                decoder,
10374                offset + 0,
10375                _depth
10376            )?;
10377            fidl::decode!(
10378                InputType,
10379                fidl::encoding::DefaultFuchsiaResourceDialect,
10380                &mut self.input_type,
10381                decoder,
10382                offset + 32,
10383                _depth
10384            )?;
10385            Ok(())
10386        }
10387    }
10388
10389    impl fidl::encoding::ResourceTypeMarker for VirtioMemStartRequest {
10390        type Borrowed<'a> = &'a mut Self;
10391        fn take_or_borrow<'a>(
10392            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10393        ) -> Self::Borrowed<'a> {
10394            value
10395        }
10396    }
10397
10398    unsafe impl fidl::encoding::TypeMarker for VirtioMemStartRequest {
10399        type Owned = Self;
10400
10401        #[inline(always)]
10402        fn inline_align(_context: fidl::encoding::Context) -> usize {
10403            8
10404        }
10405
10406        #[inline(always)]
10407        fn inline_size(_context: fidl::encoding::Context) -> usize {
10408            56
10409        }
10410    }
10411
10412    unsafe impl
10413        fidl::encoding::Encode<VirtioMemStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10414        for &mut VirtioMemStartRequest
10415    {
10416        #[inline]
10417        unsafe fn encode(
10418            self,
10419            encoder: &mut fidl::encoding::Encoder<
10420                '_,
10421                fidl::encoding::DefaultFuchsiaResourceDialect,
10422            >,
10423            offset: usize,
10424            _depth: fidl::encoding::Depth,
10425        ) -> fidl::Result<()> {
10426            encoder.debug_check_bounds::<VirtioMemStartRequest>(offset);
10427            // Delegate to tuple encoding.
10428            fidl::encoding::Encode::<
10429                VirtioMemStartRequest,
10430                fidl::encoding::DefaultFuchsiaResourceDialect,
10431            >::encode(
10432                (
10433                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10434                        &mut self.start_info,
10435                    ),
10436                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.region_addr),
10437                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.plugged_block_size),
10438                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.region_size),
10439                ),
10440                encoder,
10441                offset,
10442                _depth,
10443            )
10444        }
10445    }
10446    unsafe impl<
10447        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10448        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
10449        T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
10450        T3: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
10451    >
10452        fidl::encoding::Encode<VirtioMemStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10453        for (T0, T1, T2, T3)
10454    {
10455        #[inline]
10456        unsafe fn encode(
10457            self,
10458            encoder: &mut fidl::encoding::Encoder<
10459                '_,
10460                fidl::encoding::DefaultFuchsiaResourceDialect,
10461            >,
10462            offset: usize,
10463            depth: fidl::encoding::Depth,
10464        ) -> fidl::Result<()> {
10465            encoder.debug_check_bounds::<VirtioMemStartRequest>(offset);
10466            // Zero out padding regions. There's no need to apply masks
10467            // because the unmasked parts will be overwritten by fields.
10468            // Write the fields.
10469            self.0.encode(encoder, offset + 0, depth)?;
10470            self.1.encode(encoder, offset + 32, depth)?;
10471            self.2.encode(encoder, offset + 40, depth)?;
10472            self.3.encode(encoder, offset + 48, depth)?;
10473            Ok(())
10474        }
10475    }
10476
10477    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10478        for VirtioMemStartRequest
10479    {
10480        #[inline(always)]
10481        fn new_empty() -> Self {
10482            Self {
10483                start_info: fidl::new_empty!(
10484                    StartInfo,
10485                    fidl::encoding::DefaultFuchsiaResourceDialect
10486                ),
10487                region_addr: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
10488                plugged_block_size: fidl::new_empty!(
10489                    u64,
10490                    fidl::encoding::DefaultFuchsiaResourceDialect
10491                ),
10492                region_size: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
10493            }
10494        }
10495
10496        #[inline]
10497        unsafe fn decode(
10498            &mut self,
10499            decoder: &mut fidl::encoding::Decoder<
10500                '_,
10501                fidl::encoding::DefaultFuchsiaResourceDialect,
10502            >,
10503            offset: usize,
10504            _depth: fidl::encoding::Depth,
10505        ) -> fidl::Result<()> {
10506            decoder.debug_check_bounds::<Self>(offset);
10507            // Verify that padding bytes are zero.
10508            fidl::decode!(
10509                StartInfo,
10510                fidl::encoding::DefaultFuchsiaResourceDialect,
10511                &mut self.start_info,
10512                decoder,
10513                offset + 0,
10514                _depth
10515            )?;
10516            fidl::decode!(
10517                u64,
10518                fidl::encoding::DefaultFuchsiaResourceDialect,
10519                &mut self.region_addr,
10520                decoder,
10521                offset + 32,
10522                _depth
10523            )?;
10524            fidl::decode!(
10525                u64,
10526                fidl::encoding::DefaultFuchsiaResourceDialect,
10527                &mut self.plugged_block_size,
10528                decoder,
10529                offset + 40,
10530                _depth
10531            )?;
10532            fidl::decode!(
10533                u64,
10534                fidl::encoding::DefaultFuchsiaResourceDialect,
10535                &mut self.region_size,
10536                decoder,
10537                offset + 48,
10538                _depth
10539            )?;
10540            Ok(())
10541        }
10542    }
10543
10544    impl fidl::encoding::ResourceTypeMarker for VirtioNetStartRequest {
10545        type Borrowed<'a> = &'a mut Self;
10546        fn take_or_borrow<'a>(
10547            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10548        ) -> Self::Borrowed<'a> {
10549            value
10550        }
10551    }
10552
10553    unsafe impl fidl::encoding::TypeMarker for VirtioNetStartRequest {
10554        type Owned = Self;
10555
10556        #[inline(always)]
10557        fn inline_align(_context: fidl::encoding::Context) -> usize {
10558            8
10559        }
10560
10561        #[inline(always)]
10562        fn inline_size(_context: fidl::encoding::Context) -> usize {
10563            40
10564        }
10565    }
10566
10567    unsafe impl
10568        fidl::encoding::Encode<VirtioNetStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10569        for &mut VirtioNetStartRequest
10570    {
10571        #[inline]
10572        unsafe fn encode(
10573            self,
10574            encoder: &mut fidl::encoding::Encoder<
10575                '_,
10576                fidl::encoding::DefaultFuchsiaResourceDialect,
10577            >,
10578            offset: usize,
10579            _depth: fidl::encoding::Depth,
10580        ) -> fidl::Result<()> {
10581            encoder.debug_check_bounds::<VirtioNetStartRequest>(offset);
10582            // Delegate to tuple encoding.
10583            fidl::encoding::Encode::<
10584                VirtioNetStartRequest,
10585                fidl::encoding::DefaultFuchsiaResourceDialect,
10586            >::encode(
10587                (
10588                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10589                        &mut self.start_info,
10590                    ),
10591                    <fidl_fuchsia_net::MacAddress as fidl::encoding::ValueTypeMarker>::borrow(
10592                        &self.mac_address,
10593                    ),
10594                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_bridge),
10595                ),
10596                encoder,
10597                offset,
10598                _depth,
10599            )
10600        }
10601    }
10602    unsafe impl<
10603        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10604        T1: fidl::encoding::Encode<
10605                fidl_fuchsia_net::MacAddress,
10606                fidl::encoding::DefaultFuchsiaResourceDialect,
10607            >,
10608        T2: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
10609    >
10610        fidl::encoding::Encode<VirtioNetStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10611        for (T0, T1, T2)
10612    {
10613        #[inline]
10614        unsafe fn encode(
10615            self,
10616            encoder: &mut fidl::encoding::Encoder<
10617                '_,
10618                fidl::encoding::DefaultFuchsiaResourceDialect,
10619            >,
10620            offset: usize,
10621            depth: fidl::encoding::Depth,
10622        ) -> fidl::Result<()> {
10623            encoder.debug_check_bounds::<VirtioNetStartRequest>(offset);
10624            // Zero out padding regions. There's no need to apply masks
10625            // because the unmasked parts will be overwritten by fields.
10626            unsafe {
10627                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
10628                (ptr as *mut u64).write_unaligned(0);
10629            }
10630            // Write the fields.
10631            self.0.encode(encoder, offset + 0, depth)?;
10632            self.1.encode(encoder, offset + 32, depth)?;
10633            self.2.encode(encoder, offset + 38, depth)?;
10634            Ok(())
10635        }
10636    }
10637
10638    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10639        for VirtioNetStartRequest
10640    {
10641        #[inline(always)]
10642        fn new_empty() -> Self {
10643            Self {
10644                start_info: fidl::new_empty!(
10645                    StartInfo,
10646                    fidl::encoding::DefaultFuchsiaResourceDialect
10647                ),
10648                mac_address: fidl::new_empty!(
10649                    fidl_fuchsia_net::MacAddress,
10650                    fidl::encoding::DefaultFuchsiaResourceDialect
10651                ),
10652                enable_bridge: fidl::new_empty!(
10653                    bool,
10654                    fidl::encoding::DefaultFuchsiaResourceDialect
10655                ),
10656            }
10657        }
10658
10659        #[inline]
10660        unsafe fn decode(
10661            &mut self,
10662            decoder: &mut fidl::encoding::Decoder<
10663                '_,
10664                fidl::encoding::DefaultFuchsiaResourceDialect,
10665            >,
10666            offset: usize,
10667            _depth: fidl::encoding::Depth,
10668        ) -> fidl::Result<()> {
10669            decoder.debug_check_bounds::<Self>(offset);
10670            // Verify that padding bytes are zero.
10671            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
10672            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10673            let mask = 0xff00000000000000u64;
10674            let maskedval = padval & mask;
10675            if maskedval != 0 {
10676                return Err(fidl::Error::NonZeroPadding {
10677                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
10678                });
10679            }
10680            fidl::decode!(
10681                StartInfo,
10682                fidl::encoding::DefaultFuchsiaResourceDialect,
10683                &mut self.start_info,
10684                decoder,
10685                offset + 0,
10686                _depth
10687            )?;
10688            fidl::decode!(
10689                fidl_fuchsia_net::MacAddress,
10690                fidl::encoding::DefaultFuchsiaResourceDialect,
10691                &mut self.mac_address,
10692                decoder,
10693                offset + 32,
10694                _depth
10695            )?;
10696            fidl::decode!(
10697                bool,
10698                fidl::encoding::DefaultFuchsiaResourceDialect,
10699                &mut self.enable_bridge,
10700                decoder,
10701                offset + 38,
10702                _depth
10703            )?;
10704            Ok(())
10705        }
10706    }
10707
10708    impl fidl::encoding::ResourceTypeMarker for VirtioRngStartRequest {
10709        type Borrowed<'a> = &'a mut Self;
10710        fn take_or_borrow<'a>(
10711            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10712        ) -> Self::Borrowed<'a> {
10713            value
10714        }
10715    }
10716
10717    unsafe impl fidl::encoding::TypeMarker for VirtioRngStartRequest {
10718        type Owned = Self;
10719
10720        #[inline(always)]
10721        fn inline_align(_context: fidl::encoding::Context) -> usize {
10722            8
10723        }
10724
10725        #[inline(always)]
10726        fn inline_size(_context: fidl::encoding::Context) -> usize {
10727            32
10728        }
10729    }
10730
10731    unsafe impl
10732        fidl::encoding::Encode<VirtioRngStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10733        for &mut VirtioRngStartRequest
10734    {
10735        #[inline]
10736        unsafe fn encode(
10737            self,
10738            encoder: &mut fidl::encoding::Encoder<
10739                '_,
10740                fidl::encoding::DefaultFuchsiaResourceDialect,
10741            >,
10742            offset: usize,
10743            _depth: fidl::encoding::Depth,
10744        ) -> fidl::Result<()> {
10745            encoder.debug_check_bounds::<VirtioRngStartRequest>(offset);
10746            // Delegate to tuple encoding.
10747            fidl::encoding::Encode::<
10748                VirtioRngStartRequest,
10749                fidl::encoding::DefaultFuchsiaResourceDialect,
10750            >::encode(
10751                (<StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10752                    &mut self.start_info,
10753                ),),
10754                encoder,
10755                offset,
10756                _depth,
10757            )
10758        }
10759    }
10760    unsafe impl<
10761        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10762    >
10763        fidl::encoding::Encode<VirtioRngStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10764        for (T0,)
10765    {
10766        #[inline]
10767        unsafe fn encode(
10768            self,
10769            encoder: &mut fidl::encoding::Encoder<
10770                '_,
10771                fidl::encoding::DefaultFuchsiaResourceDialect,
10772            >,
10773            offset: usize,
10774            depth: fidl::encoding::Depth,
10775        ) -> fidl::Result<()> {
10776            encoder.debug_check_bounds::<VirtioRngStartRequest>(offset);
10777            // Zero out padding regions. There's no need to apply masks
10778            // because the unmasked parts will be overwritten by fields.
10779            // Write the fields.
10780            self.0.encode(encoder, offset + 0, depth)?;
10781            Ok(())
10782        }
10783    }
10784
10785    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10786        for VirtioRngStartRequest
10787    {
10788        #[inline(always)]
10789        fn new_empty() -> Self {
10790            Self {
10791                start_info: fidl::new_empty!(
10792                    StartInfo,
10793                    fidl::encoding::DefaultFuchsiaResourceDialect
10794                ),
10795            }
10796        }
10797
10798        #[inline]
10799        unsafe fn decode(
10800            &mut self,
10801            decoder: &mut fidl::encoding::Decoder<
10802                '_,
10803                fidl::encoding::DefaultFuchsiaResourceDialect,
10804            >,
10805            offset: usize,
10806            _depth: fidl::encoding::Depth,
10807        ) -> fidl::Result<()> {
10808            decoder.debug_check_bounds::<Self>(offset);
10809            // Verify that padding bytes are zero.
10810            fidl::decode!(
10811                StartInfo,
10812                fidl::encoding::DefaultFuchsiaResourceDialect,
10813                &mut self.start_info,
10814                decoder,
10815                offset + 0,
10816                _depth
10817            )?;
10818            Ok(())
10819        }
10820    }
10821
10822    impl fidl::encoding::ResourceTypeMarker for VirtioSoundStartRequest {
10823        type Borrowed<'a> = &'a mut Self;
10824        fn take_or_borrow<'a>(
10825            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10826        ) -> Self::Borrowed<'a> {
10827            value
10828        }
10829    }
10830
10831    unsafe impl fidl::encoding::TypeMarker for VirtioSoundStartRequest {
10832        type Owned = Self;
10833
10834        #[inline(always)]
10835        fn inline_align(_context: fidl::encoding::Context) -> usize {
10836            8
10837        }
10838
10839        #[inline(always)]
10840        fn inline_size(_context: fidl::encoding::Context) -> usize {
10841            40
10842        }
10843    }
10844
10845    unsafe impl
10846        fidl::encoding::Encode<
10847            VirtioSoundStartRequest,
10848            fidl::encoding::DefaultFuchsiaResourceDialect,
10849        > for &mut VirtioSoundStartRequest
10850    {
10851        #[inline]
10852        unsafe fn encode(
10853            self,
10854            encoder: &mut fidl::encoding::Encoder<
10855                '_,
10856                fidl::encoding::DefaultFuchsiaResourceDialect,
10857            >,
10858            offset: usize,
10859            _depth: fidl::encoding::Depth,
10860        ) -> fidl::Result<()> {
10861            encoder.debug_check_bounds::<VirtioSoundStartRequest>(offset);
10862            // Delegate to tuple encoding.
10863            fidl::encoding::Encode::<
10864                VirtioSoundStartRequest,
10865                fidl::encoding::DefaultFuchsiaResourceDialect,
10866            >::encode(
10867                (
10868                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10869                        &mut self.start_info,
10870                    ),
10871                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_input),
10872                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_verbose_logging),
10873                ),
10874                encoder,
10875                offset,
10876                _depth,
10877            )
10878        }
10879    }
10880    unsafe impl<
10881        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
10882        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
10883        T2: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
10884    >
10885        fidl::encoding::Encode<
10886            VirtioSoundStartRequest,
10887            fidl::encoding::DefaultFuchsiaResourceDialect,
10888        > for (T0, T1, T2)
10889    {
10890        #[inline]
10891        unsafe fn encode(
10892            self,
10893            encoder: &mut fidl::encoding::Encoder<
10894                '_,
10895                fidl::encoding::DefaultFuchsiaResourceDialect,
10896            >,
10897            offset: usize,
10898            depth: fidl::encoding::Depth,
10899        ) -> fidl::Result<()> {
10900            encoder.debug_check_bounds::<VirtioSoundStartRequest>(offset);
10901            // Zero out padding regions. There's no need to apply masks
10902            // because the unmasked parts will be overwritten by fields.
10903            unsafe {
10904                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
10905                (ptr as *mut u64).write_unaligned(0);
10906            }
10907            // Write the fields.
10908            self.0.encode(encoder, offset + 0, depth)?;
10909            self.1.encode(encoder, offset + 32, depth)?;
10910            self.2.encode(encoder, offset + 33, depth)?;
10911            Ok(())
10912        }
10913    }
10914
10915    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10916        for VirtioSoundStartRequest
10917    {
10918        #[inline(always)]
10919        fn new_empty() -> Self {
10920            Self {
10921                start_info: fidl::new_empty!(
10922                    StartInfo,
10923                    fidl::encoding::DefaultFuchsiaResourceDialect
10924                ),
10925                enable_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
10926                enable_verbose_logging: fidl::new_empty!(
10927                    bool,
10928                    fidl::encoding::DefaultFuchsiaResourceDialect
10929                ),
10930            }
10931        }
10932
10933        #[inline]
10934        unsafe fn decode(
10935            &mut self,
10936            decoder: &mut fidl::encoding::Decoder<
10937                '_,
10938                fidl::encoding::DefaultFuchsiaResourceDialect,
10939            >,
10940            offset: usize,
10941            _depth: fidl::encoding::Depth,
10942        ) -> fidl::Result<()> {
10943            decoder.debug_check_bounds::<Self>(offset);
10944            // Verify that padding bytes are zero.
10945            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
10946            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10947            let mask = 0xffffffffffff0000u64;
10948            let maskedval = padval & mask;
10949            if maskedval != 0 {
10950                return Err(fidl::Error::NonZeroPadding {
10951                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
10952                });
10953            }
10954            fidl::decode!(
10955                StartInfo,
10956                fidl::encoding::DefaultFuchsiaResourceDialect,
10957                &mut self.start_info,
10958                decoder,
10959                offset + 0,
10960                _depth
10961            )?;
10962            fidl::decode!(
10963                bool,
10964                fidl::encoding::DefaultFuchsiaResourceDialect,
10965                &mut self.enable_input,
10966                decoder,
10967                offset + 32,
10968                _depth
10969            )?;
10970            fidl::decode!(
10971                bool,
10972                fidl::encoding::DefaultFuchsiaResourceDialect,
10973                &mut self.enable_verbose_logging,
10974                decoder,
10975                offset + 33,
10976                _depth
10977            )?;
10978            Ok(())
10979        }
10980    }
10981
10982    impl fidl::encoding::ResourceTypeMarker for VirtioVsockStartRequest {
10983        type Borrowed<'a> = &'a mut Self;
10984        fn take_or_borrow<'a>(
10985            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10986        ) -> Self::Borrowed<'a> {
10987            value
10988        }
10989    }
10990
10991    unsafe impl fidl::encoding::TypeMarker for VirtioVsockStartRequest {
10992        type Owned = Self;
10993
10994        #[inline(always)]
10995        fn inline_align(_context: fidl::encoding::Context) -> usize {
10996            8
10997        }
10998
10999        #[inline(always)]
11000        fn inline_size(_context: fidl::encoding::Context) -> usize {
11001            56
11002        }
11003    }
11004
11005    unsafe impl
11006        fidl::encoding::Encode<
11007            VirtioVsockStartRequest,
11008            fidl::encoding::DefaultFuchsiaResourceDialect,
11009        > for &mut VirtioVsockStartRequest
11010    {
11011        #[inline]
11012        unsafe fn encode(
11013            self,
11014            encoder: &mut fidl::encoding::Encoder<
11015                '_,
11016                fidl::encoding::DefaultFuchsiaResourceDialect,
11017            >,
11018            offset: usize,
11019            _depth: fidl::encoding::Depth,
11020        ) -> fidl::Result<()> {
11021            encoder.debug_check_bounds::<VirtioVsockStartRequest>(offset);
11022            // Delegate to tuple encoding.
11023            fidl::encoding::Encode::<VirtioVsockStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11024                (
11025                    <StartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.start_info),
11026                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.guest_cid),
11027                    <fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listeners),
11028                ),
11029                encoder, offset, _depth
11030            )
11031        }
11032    }
11033    unsafe impl<
11034        T0: fidl::encoding::Encode<StartInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
11035        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
11036        T2: fidl::encoding::Encode<
11037                fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
11038                fidl::encoding::DefaultFuchsiaResourceDialect,
11039            >,
11040    >
11041        fidl::encoding::Encode<
11042            VirtioVsockStartRequest,
11043            fidl::encoding::DefaultFuchsiaResourceDialect,
11044        > for (T0, T1, T2)
11045    {
11046        #[inline]
11047        unsafe fn encode(
11048            self,
11049            encoder: &mut fidl::encoding::Encoder<
11050                '_,
11051                fidl::encoding::DefaultFuchsiaResourceDialect,
11052            >,
11053            offset: usize,
11054            depth: fidl::encoding::Depth,
11055        ) -> fidl::Result<()> {
11056            encoder.debug_check_bounds::<VirtioVsockStartRequest>(offset);
11057            // Zero out padding regions. There's no need to apply masks
11058            // because the unmasked parts will be overwritten by fields.
11059            unsafe {
11060                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
11061                (ptr as *mut u64).write_unaligned(0);
11062            }
11063            // Write the fields.
11064            self.0.encode(encoder, offset + 0, depth)?;
11065            self.1.encode(encoder, offset + 32, depth)?;
11066            self.2.encode(encoder, offset + 40, depth)?;
11067            Ok(())
11068        }
11069    }
11070
11071    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11072        for VirtioVsockStartRequest
11073    {
11074        #[inline(always)]
11075        fn new_empty() -> Self {
11076            Self {
11077                start_info: fidl::new_empty!(
11078                    StartInfo,
11079                    fidl::encoding::DefaultFuchsiaResourceDialect
11080                ),
11081                guest_cid: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
11082                listeners: fidl::new_empty!(
11083                    fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
11084                    fidl::encoding::DefaultFuchsiaResourceDialect
11085                ),
11086            }
11087        }
11088
11089        #[inline]
11090        unsafe fn decode(
11091            &mut self,
11092            decoder: &mut fidl::encoding::Decoder<
11093                '_,
11094                fidl::encoding::DefaultFuchsiaResourceDialect,
11095            >,
11096            offset: usize,
11097            _depth: fidl::encoding::Depth,
11098        ) -> fidl::Result<()> {
11099            decoder.debug_check_bounds::<Self>(offset);
11100            // Verify that padding bytes are zero.
11101            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
11102            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11103            let mask = 0xffffffff00000000u64;
11104            let maskedval = padval & mask;
11105            if maskedval != 0 {
11106                return Err(fidl::Error::NonZeroPadding {
11107                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
11108                });
11109            }
11110            fidl::decode!(
11111                StartInfo,
11112                fidl::encoding::DefaultFuchsiaResourceDialect,
11113                &mut self.start_info,
11114                decoder,
11115                offset + 0,
11116                _depth
11117            )?;
11118            fidl::decode!(
11119                u32,
11120                fidl::encoding::DefaultFuchsiaResourceDialect,
11121                &mut self.guest_cid,
11122                decoder,
11123                offset + 32,
11124                _depth
11125            )?;
11126            fidl::decode!(
11127                fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::Listener>,
11128                fidl::encoding::DefaultFuchsiaResourceDialect,
11129                &mut self.listeners,
11130                decoder,
11131                offset + 40,
11132                _depth
11133            )?;
11134            Ok(())
11135        }
11136    }
11137
11138    impl fidl::encoding::ResourceTypeMarker for InputType {
11139        type Borrowed<'a> = &'a mut Self;
11140        fn take_or_borrow<'a>(
11141            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11142        ) -> Self::Borrowed<'a> {
11143            value
11144        }
11145    }
11146
11147    unsafe impl fidl::encoding::TypeMarker for InputType {
11148        type Owned = Self;
11149
11150        #[inline(always)]
11151        fn inline_align(_context: fidl::encoding::Context) -> usize {
11152            8
11153        }
11154
11155        #[inline(always)]
11156        fn inline_size(_context: fidl::encoding::Context) -> usize {
11157            16
11158        }
11159    }
11160
11161    unsafe impl fidl::encoding::Encode<InputType, fidl::encoding::DefaultFuchsiaResourceDialect>
11162        for &mut InputType
11163    {
11164        #[inline]
11165        unsafe fn encode(
11166            self,
11167            encoder: &mut fidl::encoding::Encoder<
11168                '_,
11169                fidl::encoding::DefaultFuchsiaResourceDialect,
11170            >,
11171            offset: usize,
11172            _depth: fidl::encoding::Depth,
11173        ) -> fidl::Result<()> {
11174            encoder.debug_check_bounds::<InputType>(offset);
11175            encoder.write_num::<u64>(self.ordinal(), offset);
11176            match self {
11177                InputType::Keyboard(ref mut val) => fidl::encoding::encode_in_envelope::<
11178                    fidl::encoding::Endpoint<
11179                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
11180                    >,
11181                    fidl::encoding::DefaultFuchsiaResourceDialect,
11182                >(
11183                    <fidl::encoding::Endpoint<
11184                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
11185                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11186                        val
11187                    ),
11188                    encoder,
11189                    offset + 8,
11190                    _depth,
11191                ),
11192                InputType::Mouse(ref mut val) => fidl::encoding::encode_in_envelope::<
11193                    fidl::encoding::Endpoint<
11194                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
11195                    >,
11196                    fidl::encoding::DefaultFuchsiaResourceDialect,
11197                >(
11198                    <fidl::encoding::Endpoint<
11199                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
11200                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11201                        val
11202                    ),
11203                    encoder,
11204                    offset + 8,
11205                    _depth,
11206                ),
11207            }
11208        }
11209    }
11210
11211    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for InputType {
11212        #[inline(always)]
11213        fn new_empty() -> Self {
11214            Self::Keyboard(fidl::new_empty!(
11215                fidl::encoding::Endpoint<
11216                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
11217                >,
11218                fidl::encoding::DefaultFuchsiaResourceDialect
11219            ))
11220        }
11221
11222        #[inline]
11223        unsafe fn decode(
11224            &mut self,
11225            decoder: &mut fidl::encoding::Decoder<
11226                '_,
11227                fidl::encoding::DefaultFuchsiaResourceDialect,
11228            >,
11229            offset: usize,
11230            mut depth: fidl::encoding::Depth,
11231        ) -> fidl::Result<()> {
11232            decoder.debug_check_bounds::<Self>(offset);
11233            #[allow(unused_variables)]
11234            let next_out_of_line = decoder.next_out_of_line();
11235            let handles_before = decoder.remaining_handles();
11236            let (ordinal, inlined, num_bytes, num_handles) =
11237                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
11238
11239            let member_inline_size = match ordinal {
11240                1 => <fidl::encoding::Endpoint<
11241                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
11242                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11243                2 => <fidl::encoding::Endpoint<
11244                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
11245                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11246                _ => return Err(fidl::Error::UnknownUnionTag),
11247            };
11248
11249            if inlined != (member_inline_size <= 4) {
11250                return Err(fidl::Error::InvalidInlineBitInEnvelope);
11251            }
11252            let _inner_offset;
11253            if inlined {
11254                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
11255                _inner_offset = offset + 8;
11256            } else {
11257                depth.increment()?;
11258                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11259            }
11260            match ordinal {
11261                1 => {
11262                    #[allow(irrefutable_let_patterns)]
11263                    if let InputType::Keyboard(_) = self {
11264                        // Do nothing, read the value into the object
11265                    } else {
11266                        // Initialize `self` to the right variant
11267                        *self = InputType::Keyboard(fidl::new_empty!(
11268                            fidl::encoding::Endpoint<
11269                                fidl::endpoints::ServerEnd<
11270                                    fidl_fuchsia_ui_input3::KeyboardListenerMarker,
11271                                >,
11272                            >,
11273                            fidl::encoding::DefaultFuchsiaResourceDialect
11274                        ));
11275                    }
11276                    #[allow(irrefutable_let_patterns)]
11277                    if let InputType::Keyboard(ref mut val) = self {
11278                        fidl::decode!(
11279                            fidl::encoding::Endpoint<
11280                                fidl::endpoints::ServerEnd<
11281                                    fidl_fuchsia_ui_input3::KeyboardListenerMarker,
11282                                >,
11283                            >,
11284                            fidl::encoding::DefaultFuchsiaResourceDialect,
11285                            val,
11286                            decoder,
11287                            _inner_offset,
11288                            depth
11289                        )?;
11290                    } else {
11291                        unreachable!()
11292                    }
11293                }
11294                2 => {
11295                    #[allow(irrefutable_let_patterns)]
11296                    if let InputType::Mouse(_) = self {
11297                        // Do nothing, read the value into the object
11298                    } else {
11299                        // Initialize `self` to the right variant
11300                        *self = InputType::Mouse(fidl::new_empty!(
11301                            fidl::encoding::Endpoint<
11302                                fidl::endpoints::ClientEnd<
11303                                    fidl_fuchsia_ui_pointer::MouseSourceMarker,
11304                                >,
11305                            >,
11306                            fidl::encoding::DefaultFuchsiaResourceDialect
11307                        ));
11308                    }
11309                    #[allow(irrefutable_let_patterns)]
11310                    if let InputType::Mouse(ref mut val) = self {
11311                        fidl::decode!(
11312                            fidl::encoding::Endpoint<
11313                                fidl::endpoints::ClientEnd<
11314                                    fidl_fuchsia_ui_pointer::MouseSourceMarker,
11315                                >,
11316                            >,
11317                            fidl::encoding::DefaultFuchsiaResourceDialect,
11318                            val,
11319                            decoder,
11320                            _inner_offset,
11321                            depth
11322                        )?;
11323                    } else {
11324                        unreachable!()
11325                    }
11326                }
11327                ordinal => panic!("unexpected ordinal {:?}", ordinal),
11328            }
11329            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
11330                return Err(fidl::Error::InvalidNumBytesInEnvelope);
11331            }
11332            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11333                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11334            }
11335            Ok(())
11336        }
11337    }
11338}