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