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