#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use bitflags::bitflags;
use fidl::client::QueryResponseFut;
use fidl::endpoints::{ControlHandle as _, Responder as _};
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
pub const EVENT_SET_CONFIG: u32 = 1;
pub const EVENT_SET_INTERRUPT: u32 = 2;
pub const EVENT_SET_QUEUE: u32 = 0;
pub const VIRTIO_WAYLAND_INVALID_VFD_ID: u32 = 0;
pub const VIRTIO_WAYLAND_MAX_IMAGE_INFO_SIZE: u32 = 128;
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct StartInfo {
pub trap: Trap,
pub guest: Option<fidl::Guest>,
pub event: fidl::Event,
pub vmo: fidl::Vmo,
}
impl fidl::Standalone for StartInfo {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct Trap {
pub addr: u64,
pub size: u64,
}
impl fidl::Persistable for Trap {}
#[derive(Clone, Debug, PartialEq)]
pub struct VirtioBalloonGetMemStatsResponse {
pub status: i32,
pub mem_stats: Option<Vec<fidl_fuchsia_virtualization::MemStat>>,
}
impl fidl::Persistable for VirtioBalloonGetMemStatsResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioBalloonStartRequest {
pub start_info: StartInfo,
}
impl fidl::Standalone for VirtioBalloonStartRequest {}
#[derive(Debug, PartialEq)]
pub struct VirtioBlockStartRequest {
pub start_info: StartInfo,
pub spec: fidl_fuchsia_virtualization::BlockSpec,
}
impl fidl::Standalone for VirtioBlockStartRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioBlockStartResponse {
pub capacity: u64,
pub block_size: u32,
}
impl fidl::Persistable for VirtioBlockStartResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioConsoleStartRequest {
pub start_info: StartInfo,
pub socket: fidl::Socket,
}
impl fidl::Standalone for VirtioConsoleStartRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioDeviceConfigureQueueRequest {
pub queue: u16,
pub size: u16,
pub desc: u64,
pub avail: u64,
pub used: u64,
}
impl fidl::Persistable for VirtioDeviceConfigureQueueRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioDeviceNotifyQueueRequest {
pub queue: u16,
}
impl fidl::Persistable for VirtioDeviceNotifyQueueRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioDeviceReadyRequest {
pub negotiated_features: u32,
}
impl fidl::Persistable for VirtioDeviceReadyRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioGpuStartRequest {
pub start_info: StartInfo,
pub keyboard_listener:
Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
pub mouse_source:
Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
}
impl fidl::Standalone for VirtioGpuStartRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioImage {
pub vmo: fidl::Vmo,
pub token: Option<fidl::EventPair>,
pub info: Vec<u8>,
}
impl fidl::Standalone for VirtioImage {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioInputStartRequest {
pub start_info: StartInfo,
pub input_type: InputType,
}
impl fidl::Standalone for VirtioInputStartRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioMagmaStartRequest {
pub start_info: StartInfo,
pub vmar: fidl::Vmar,
pub wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
}
impl fidl::Standalone for VirtioMagmaStartRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioMagmaStartResponse {
pub status: i32,
}
impl fidl::Persistable for VirtioMagmaStartResponse {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioMemOnConfigChangedRequest {
pub plugged_size: u64,
}
impl fidl::Persistable for VirtioMemOnConfigChangedRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioMemStartRequest {
pub start_info: StartInfo,
pub region_addr: u64,
pub plugged_block_size: u64,
pub region_size: u64,
}
impl fidl::Standalone for VirtioMemStartRequest {}
#[derive(Debug, PartialEq)]
pub struct VirtioNetStartRequest {
pub start_info: StartInfo,
pub mac_address: fidl_fuchsia_net::MacAddress,
pub enable_bridge: bool,
}
impl fidl::Standalone for VirtioNetStartRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioRngStartRequest {
pub start_info: StartInfo,
}
impl fidl::Standalone for VirtioRngStartRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioSoundStartRequest {
pub start_info: StartInfo,
pub enable_input: bool,
pub enable_verbose_logging: bool,
}
impl fidl::Standalone for VirtioSoundStartRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioSoundStartResponse {
pub features: u32,
pub jacks: u32,
pub streams: u32,
pub chmaps: u32,
}
impl fidl::Persistable for VirtioSoundStartResponse {}
#[derive(Debug, PartialEq)]
pub struct VirtioVsockStartRequest {
pub start_info: StartInfo,
pub guest_cid: u32,
pub listeners: Vec<fidl_fuchsia_virtualization::Listener>,
}
impl fidl::Standalone for VirtioVsockStartRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioWaylandGetImporterRequest {
pub importer: fidl::endpoints::ServerEnd<VirtioWaylandImporterMarker>,
}
impl fidl::Standalone for VirtioWaylandGetImporterRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioWaylandImporterExportImageRequest {
pub vfd_id: u32,
}
impl fidl::Persistable for VirtioWaylandImporterExportImageRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioWaylandImporterExportImageResponse {
pub status: i32,
pub image: Option<Box<VirtioImage>>,
}
impl fidl::Standalone for VirtioWaylandImporterExportImageResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioWaylandImporterImportImageRequest {
pub image: VirtioImage,
}
impl fidl::Standalone for VirtioWaylandImporterImportImageRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct VirtioWaylandImporterImportImageResponse {
pub vfd_id: u32,
}
impl fidl::Persistable for VirtioWaylandImporterImportImageResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioWaylandStartRequest {
pub start_info: StartInfo,
pub vmar: fidl::Vmar,
pub sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
pub scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
}
impl fidl::Standalone for VirtioWaylandStartRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VirtioWaylandStartWithWaylandServerRequest {
pub start_info: StartInfo,
pub vmar: fidl::Vmar,
pub wayland_server: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_wayland::Server_Marker>>,
pub sysmem_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
pub scenic_allocator: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_composition::AllocatorMarker>,
}
impl fidl::Standalone for VirtioWaylandStartWithWaylandServerRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum InputType {
Keyboard(fidl::endpoints::ServerEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>),
Mouse(fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>),
}
impl InputType {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Keyboard(_) => 1,
Self::Mouse(_) => 2,
}
}
#[deprecated = "Strict unions should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
impl fidl::Standalone for InputType {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioBalloonMarker;
impl fidl::endpoints::ProtocolMarker for VirtioBalloonMarker {
type Proxy = VirtioBalloonProxy;
type RequestStream = VirtioBalloonRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioBalloonSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioBalloon";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioBalloonMarker {}
pub trait VirtioBalloonProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#start(&self, start_info: StartInfo) -> Self::StartResponseFut;
type GetMemStatsResponseFut: std::future::Future<
Output = Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error>,
> + Send;
fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioBalloonSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioBalloonSynchronousProxy {
type Proxy = VirtioBalloonProxy;
type Protocol = VirtioBalloonMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioBalloonSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioBalloonEvent, fidl::Error> {
VirtioBalloonEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioBalloonStartRequest, fidl::encoding::EmptyPayload>(
(&mut start_info,),
0x26645282fddf6f46,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#get_mem_stats(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error> {
let _response = self
.client
.send_query::<fidl::encoding::EmptyPayload, VirtioBalloonGetMemStatsResponse>(
(),
0x6641f4c296607e24,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok((_response.status, _response.mem_stats))
}
}
#[derive(Debug, Clone)]
pub struct VirtioBalloonProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioBalloonProxy {
type Protocol = VirtioBalloonMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioBalloonProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioBalloonEventStream {
VirtioBalloonEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioBalloonProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioBalloonProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioBalloonProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(&self, mut start_info: StartInfo) -> fidl::client::QueryResponseFut<()> {
VirtioBalloonProxyInterface::r#start(self, start_info)
}
pub fn r#get_mem_stats(
&self,
) -> fidl::client::QueryResponseFut<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>)>
{
VirtioBalloonProxyInterface::r#get_mem_stats(self)
}
}
impl VirtioBalloonProxyInterface for VirtioBalloonProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<()>;
fn r#start(&self, mut start_info: StartInfo) -> Self::StartResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x26645282fddf6f46,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioBalloonStartRequest, ()>(
(&mut start_info,),
0x26645282fddf6f46,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type GetMemStatsResponseFut =
fidl::client::QueryResponseFut<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>)>;
fn r#get_mem_stats(&self) -> Self::GetMemStatsResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
VirtioBalloonGetMemStatsResponse,
0x6641f4c296607e24,
>(_buf?)?;
Ok((_response.status, _response.mem_stats))
}
self.client.send_query_and_decode::<
fidl::encoding::EmptyPayload,
(i32, Option<Vec<fidl_fuchsia_virtualization::MemStat>>),
>(
(),
0x6641f4c296607e24,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioBalloonEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioBalloonEventStream {}
impl futures::stream::FusedStream for VirtioBalloonEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioBalloonEventStream {
type Item = Result<VirtioBalloonEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioBalloonEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioBalloonEvent {}
impl VirtioBalloonEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioBalloonEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioBalloonRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioBalloonRequestStream {}
impl futures::stream::FusedStream for VirtioBalloonRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioBalloonRequestStream {
type Protocol = VirtioBalloonMarker;
type ControlHandle = VirtioBalloonControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioBalloonControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioBalloonRequestStream {
type Item = Result<VirtioBalloonRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioBalloonRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBalloonControlHandle { inner: this.inner.clone() };
Ok(VirtioBalloonRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioBalloonConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBalloonControlHandle { inner: this.inner.clone() };
Ok(VirtioBalloonRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBalloonControlHandle { inner: this.inner.clone() };
Ok(VirtioBalloonRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioBalloonReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x26645282fddf6f46 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioBalloonStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioBalloonStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBalloonControlHandle { inner: this.inner.clone() };
Ok(VirtioBalloonRequest::Start {
start_info: req.start_info,
responder: VirtioBalloonStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6641f4c296607e24 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
fidl::encoding::EmptyPayload,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBalloonControlHandle { inner: this.inner.clone() };
Ok(VirtioBalloonRequest::GetMemStats {
responder: VirtioBalloonGetMemStatsResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<VirtioBalloonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioBalloonRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioBalloonConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioBalloonControlHandle },
Ready { negotiated_features: u32, responder: VirtioBalloonReadyResponder },
Start { start_info: StartInfo, responder: VirtioBalloonStartResponder },
GetMemStats { responder: VirtioBalloonGetMemStatsResponder },
}
impl VirtioBalloonRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioBalloonConfigureQueueResponder)> {
if let VirtioBalloonRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioBalloonControlHandle)> {
if let VirtioBalloonRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioBalloonReadyResponder)> {
if let VirtioBalloonRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(self) -> Option<(StartInfo, VirtioBalloonStartResponder)> {
if let VirtioBalloonRequest::Start { start_info, responder } = self {
Some((start_info, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_get_mem_stats(self) -> Option<(VirtioBalloonGetMemStatsResponder)> {
if let VirtioBalloonRequest::GetMemStats { responder } = self {
Some((responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioBalloonRequest::ConfigureQueue { .. } => "configure_queue",
VirtioBalloonRequest::NotifyQueue { .. } => "notify_queue",
VirtioBalloonRequest::Ready { .. } => "ready",
VirtioBalloonRequest::Start { .. } => "start",
VirtioBalloonRequest::GetMemStats { .. } => "get_mem_stats",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioBalloonControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioBalloonControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioBalloonControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioBalloonConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioBalloonConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioBalloonConfigureQueueResponder {
type ControlHandle = VirtioBalloonControlHandle;
fn control_handle(&self) -> &VirtioBalloonControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioBalloonConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioBalloonReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioBalloonReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioBalloonReadyResponder {
type ControlHandle = VirtioBalloonControlHandle;
fn control_handle(&self) -> &VirtioBalloonControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioBalloonReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioBalloonStartResponder {
control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioBalloonStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioBalloonStartResponder {
type ControlHandle = VirtioBalloonControlHandle;
fn control_handle(&self) -> &VirtioBalloonControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioBalloonStartResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x26645282fddf6f46,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioBalloonGetMemStatsResponder {
control_handle: std::mem::ManuallyDrop<VirtioBalloonControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioBalloonGetMemStatsResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioBalloonGetMemStatsResponder {
type ControlHandle = VirtioBalloonControlHandle;
fn control_handle(&self) -> &VirtioBalloonControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioBalloonGetMemStatsResponder {
pub fn send(
self,
mut status: i32,
mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(status, mem_stats);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut status: i32,
mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(status, mem_stats);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut status: i32,
mut mem_stats: Option<&[fidl_fuchsia_virtualization::MemStat]>,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<VirtioBalloonGetMemStatsResponse>(
(status, mem_stats),
self.tx_id,
0x6641f4c296607e24,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioBlockMarker;
impl fidl::endpoints::ProtocolMarker for VirtioBlockMarker {
type Proxy = VirtioBlockProxy;
type RequestStream = VirtioBlockRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioBlockSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioBlock";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioBlockMarker {}
pub trait VirtioBlockProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<(u64, u32), fidl::Error>> + Send;
fn r#start(
&self,
start_info: StartInfo,
spec: fidl_fuchsia_virtualization::BlockSpec,
) -> Self::StartResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioBlockSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioBlockSynchronousProxy {
type Proxy = VirtioBlockProxy;
type Protocol = VirtioBlockMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioBlockSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioBlockEvent, fidl::Error> {
VirtioBlockEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut spec: fidl_fuchsia_virtualization::BlockSpec,
___deadline: zx::MonotonicInstant,
) -> Result<(u64, u32), fidl::Error> {
let _response =
self.client.send_query::<VirtioBlockStartRequest, VirtioBlockStartResponse>(
(&mut start_info, &mut spec),
0x5ef6a4b9ce9adcb2,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok((_response.capacity, _response.block_size))
}
}
#[derive(Debug, Clone)]
pub struct VirtioBlockProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioBlockProxy {
type Protocol = VirtioBlockMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioBlockProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioBlockEventStream {
VirtioBlockEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioBlockProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioBlockProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioBlockProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut spec: fidl_fuchsia_virtualization::BlockSpec,
) -> fidl::client::QueryResponseFut<(u64, u32)> {
VirtioBlockProxyInterface::r#start(self, start_info, spec)
}
}
impl VirtioBlockProxyInterface for VirtioBlockProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<(u64, u32)>;
fn r#start(
&self,
mut start_info: StartInfo,
mut spec: fidl_fuchsia_virtualization::BlockSpec,
) -> Self::StartResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<(u64, u32), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
VirtioBlockStartResponse,
0x5ef6a4b9ce9adcb2,
>(_buf?)?;
Ok((_response.capacity, _response.block_size))
}
self.client.send_query_and_decode::<VirtioBlockStartRequest, (u64, u32)>(
(&mut start_info, &mut spec),
0x5ef6a4b9ce9adcb2,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioBlockEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioBlockEventStream {}
impl futures::stream::FusedStream for VirtioBlockEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioBlockEventStream {
type Item = Result<VirtioBlockEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioBlockEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioBlockEvent {}
impl VirtioBlockEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioBlockEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioBlockRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioBlockRequestStream {}
impl futures::stream::FusedStream for VirtioBlockRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioBlockRequestStream {
type Protocol = VirtioBlockMarker;
type ControlHandle = VirtioBlockControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioBlockControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioBlockRequestStream {
type Item = Result<VirtioBlockRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioBlockRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
Ok(VirtioBlockRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioBlockConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
Ok(VirtioBlockRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
Ok(VirtioBlockRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioBlockReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x5ef6a4b9ce9adcb2 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioBlockStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioBlockStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioBlockControlHandle { inner: this.inner.clone() };
Ok(VirtioBlockRequest::Start {
start_info: req.start_info,
spec: req.spec,
responder: VirtioBlockStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<VirtioBlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioBlockRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioBlockConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioBlockControlHandle },
Ready { negotiated_features: u32, responder: VirtioBlockReadyResponder },
Start {
start_info: StartInfo,
spec: fidl_fuchsia_virtualization::BlockSpec,
responder: VirtioBlockStartResponder,
},
}
impl VirtioBlockRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioBlockConfigureQueueResponder)> {
if let VirtioBlockRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioBlockControlHandle)> {
if let VirtioBlockRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioBlockReadyResponder)> {
if let VirtioBlockRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(
self,
) -> Option<(StartInfo, fidl_fuchsia_virtualization::BlockSpec, VirtioBlockStartResponder)>
{
if let VirtioBlockRequest::Start { start_info, spec, responder } = self {
Some((start_info, spec, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioBlockRequest::ConfigureQueue { .. } => "configure_queue",
VirtioBlockRequest::NotifyQueue { .. } => "notify_queue",
VirtioBlockRequest::Ready { .. } => "ready",
VirtioBlockRequest::Start { .. } => "start",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioBlockControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioBlockControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioBlockControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioBlockConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioBlockConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioBlockConfigureQueueResponder {
type ControlHandle = VirtioBlockControlHandle;
fn control_handle(&self) -> &VirtioBlockControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioBlockConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioBlockReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioBlockReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioBlockReadyResponder {
type ControlHandle = VirtioBlockControlHandle;
fn control_handle(&self) -> &VirtioBlockControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioBlockReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioBlockStartResponder {
control_handle: std::mem::ManuallyDrop<VirtioBlockControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioBlockStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioBlockStartResponder {
type ControlHandle = VirtioBlockControlHandle;
fn control_handle(&self) -> &VirtioBlockControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioBlockStartResponder {
pub fn send(self, mut capacity: u64, mut block_size: u32) -> Result<(), fidl::Error> {
let _result = self.send_raw(capacity, block_size);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut capacity: u64,
mut block_size: u32,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(capacity, block_size);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut capacity: u64, mut block_size: u32) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<VirtioBlockStartResponse>(
(capacity, block_size),
self.tx_id,
0x5ef6a4b9ce9adcb2,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioConsoleMarker;
impl fidl::endpoints::ProtocolMarker for VirtioConsoleMarker {
type Proxy = VirtioConsoleProxy;
type RequestStream = VirtioConsoleRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioConsoleSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioConsole";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioConsoleMarker {}
pub trait VirtioConsoleProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#start(&self, start_info: StartInfo, socket: fidl::Socket) -> Self::StartResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioConsoleSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioConsoleSynchronousProxy {
type Proxy = VirtioConsoleProxy;
type Protocol = VirtioConsoleMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioConsoleSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioConsoleEvent, fidl::Error> {
VirtioConsoleEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut socket: fidl::Socket,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioConsoleStartRequest, fidl::encoding::EmptyPayload>(
(&mut start_info, socket),
0x10a6267f2ab7e24c,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct VirtioConsoleProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioConsoleProxy {
type Protocol = VirtioConsoleMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioConsoleProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioConsoleEventStream {
VirtioConsoleEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioConsoleProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioConsoleProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioConsoleProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut socket: fidl::Socket,
) -> fidl::client::QueryResponseFut<()> {
VirtioConsoleProxyInterface::r#start(self, start_info, socket)
}
}
impl VirtioConsoleProxyInterface for VirtioConsoleProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<()>;
fn r#start(
&self,
mut start_info: StartInfo,
mut socket: fidl::Socket,
) -> Self::StartResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x10a6267f2ab7e24c,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioConsoleStartRequest, ()>(
(&mut start_info, socket),
0x10a6267f2ab7e24c,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioConsoleEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioConsoleEventStream {}
impl futures::stream::FusedStream for VirtioConsoleEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioConsoleEventStream {
type Item = Result<VirtioConsoleEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioConsoleEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioConsoleEvent {}
impl VirtioConsoleEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioConsoleEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioConsoleRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioConsoleRequestStream {}
impl futures::stream::FusedStream for VirtioConsoleRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioConsoleRequestStream {
type Protocol = VirtioConsoleMarker;
type ControlHandle = VirtioConsoleControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioConsoleControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioConsoleRequestStream {
type Item = Result<VirtioConsoleRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioConsoleRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioConsoleControlHandle { inner: this.inner.clone() };
Ok(VirtioConsoleRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioConsoleConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioConsoleControlHandle { inner: this.inner.clone() };
Ok(VirtioConsoleRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioConsoleControlHandle { inner: this.inner.clone() };
Ok(VirtioConsoleRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioConsoleReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x10a6267f2ab7e24c => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioConsoleStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioConsoleStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioConsoleControlHandle { inner: this.inner.clone() };
Ok(VirtioConsoleRequest::Start {
start_info: req.start_info,
socket: req.socket,
responder: VirtioConsoleStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<VirtioConsoleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioConsoleRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioConsoleConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioConsoleControlHandle },
Ready { negotiated_features: u32, responder: VirtioConsoleReadyResponder },
Start { start_info: StartInfo, socket: fidl::Socket, responder: VirtioConsoleStartResponder },
}
impl VirtioConsoleRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioConsoleConfigureQueueResponder)> {
if let VirtioConsoleRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioConsoleControlHandle)> {
if let VirtioConsoleRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioConsoleReadyResponder)> {
if let VirtioConsoleRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(self) -> Option<(StartInfo, fidl::Socket, VirtioConsoleStartResponder)> {
if let VirtioConsoleRequest::Start { start_info, socket, responder } = self {
Some((start_info, socket, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioConsoleRequest::ConfigureQueue { .. } => "configure_queue",
VirtioConsoleRequest::NotifyQueue { .. } => "notify_queue",
VirtioConsoleRequest::Ready { .. } => "ready",
VirtioConsoleRequest::Start { .. } => "start",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioConsoleControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioConsoleControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioConsoleControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioConsoleConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioConsoleConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioConsoleConfigureQueueResponder {
type ControlHandle = VirtioConsoleControlHandle;
fn control_handle(&self) -> &VirtioConsoleControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioConsoleConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioConsoleReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioConsoleReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioConsoleReadyResponder {
type ControlHandle = VirtioConsoleControlHandle;
fn control_handle(&self) -> &VirtioConsoleControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioConsoleReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioConsoleStartResponder {
control_handle: std::mem::ManuallyDrop<VirtioConsoleControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioConsoleStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioConsoleStartResponder {
type ControlHandle = VirtioConsoleControlHandle;
fn control_handle(&self) -> &VirtioConsoleControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioConsoleStartResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x10a6267f2ab7e24c,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioDeviceMarker;
impl fidl::endpoints::ProtocolMarker for VirtioDeviceMarker {
type Proxy = VirtioDeviceProxy;
type RequestStream = VirtioDeviceRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioDeviceSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) VirtioDevice";
}
pub trait VirtioDeviceProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioDeviceSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioDeviceSynchronousProxy {
type Proxy = VirtioDeviceProxy;
type Protocol = VirtioDeviceMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioDeviceSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioDeviceEvent, fidl::Error> {
VirtioDeviceEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct VirtioDeviceProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioDeviceProxy {
type Protocol = VirtioDeviceMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioDeviceProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioDeviceEventStream {
VirtioDeviceEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioDeviceProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioDeviceProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioDeviceProxyInterface::r#ready(self, negotiated_features)
}
}
impl VirtioDeviceProxyInterface for VirtioDeviceProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioDeviceEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioDeviceEventStream {}
impl futures::stream::FusedStream for VirtioDeviceEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioDeviceEventStream {
type Item = Result<VirtioDeviceEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioDeviceEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioDeviceEvent {}
impl VirtioDeviceEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioDeviceEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioDeviceRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioDeviceRequestStream {}
impl futures::stream::FusedStream for VirtioDeviceRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioDeviceRequestStream {
type Protocol = VirtioDeviceMarker;
type ControlHandle = VirtioDeviceControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioDeviceControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioDeviceRequestStream {
type Item = Result<VirtioDeviceRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioDeviceRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioDeviceControlHandle { inner: this.inner.clone() };
Ok(VirtioDeviceRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioDeviceConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioDeviceControlHandle { inner: this.inner.clone() };
Ok(VirtioDeviceRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioDeviceControlHandle { inner: this.inner.clone() };
Ok(VirtioDeviceRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioDeviceReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<VirtioDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioDeviceRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioDeviceConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioDeviceControlHandle },
Ready { negotiated_features: u32, responder: VirtioDeviceReadyResponder },
}
impl VirtioDeviceRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioDeviceConfigureQueueResponder)> {
if let VirtioDeviceRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioDeviceControlHandle)> {
if let VirtioDeviceRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioDeviceReadyResponder)> {
if let VirtioDeviceRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioDeviceRequest::ConfigureQueue { .. } => "configure_queue",
VirtioDeviceRequest::NotifyQueue { .. } => "notify_queue",
VirtioDeviceRequest::Ready { .. } => "ready",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioDeviceControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioDeviceControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioDeviceControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioDeviceConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioDeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioDeviceConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioDeviceConfigureQueueResponder {
type ControlHandle = VirtioDeviceControlHandle;
fn control_handle(&self) -> &VirtioDeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioDeviceConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioDeviceReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioDeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioDeviceReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioDeviceReadyResponder {
type ControlHandle = VirtioDeviceControlHandle;
fn control_handle(&self) -> &VirtioDeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioDeviceReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioGpuMarker;
impl fidl::endpoints::ProtocolMarker for VirtioGpuMarker {
type Proxy = VirtioGpuProxy;
type RequestStream = VirtioGpuRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioGpuSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioGpu";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioGpuMarker {}
pub trait VirtioGpuProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#start(
&self,
start_info: StartInfo,
keyboard_listener: Option<
fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
>,
mouse_source: Option<
fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
>,
) -> Self::StartResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioGpuSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioGpuSynchronousProxy {
type Proxy = VirtioGpuProxy;
type Protocol = VirtioGpuMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioGpuSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioGpuEvent, fidl::Error> {
VirtioGpuEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut keyboard_listener: Option<
fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
>,
mut mouse_source: Option<
fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
>,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioGpuStartRequest, fidl::encoding::EmptyPayload>(
(&mut start_info, keyboard_listener, mouse_source),
0x7e81ed410f770c14,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct VirtioGpuProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioGpuProxy {
type Protocol = VirtioGpuMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioGpuProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioGpuEventStream {
VirtioGpuEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioGpuProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioGpuProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioGpuProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut keyboard_listener: Option<
fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
>,
mut mouse_source: Option<
fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
>,
) -> fidl::client::QueryResponseFut<()> {
VirtioGpuProxyInterface::r#start(self, start_info, keyboard_listener, mouse_source)
}
}
impl VirtioGpuProxyInterface for VirtioGpuProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<()>;
fn r#start(
&self,
mut start_info: StartInfo,
mut keyboard_listener: Option<
fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>,
>,
mut mouse_source: Option<
fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
>,
) -> Self::StartResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x7e81ed410f770c14,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioGpuStartRequest, ()>(
(&mut start_info, keyboard_listener, mouse_source),
0x7e81ed410f770c14,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioGpuEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioGpuEventStream {}
impl futures::stream::FusedStream for VirtioGpuEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioGpuEventStream {
type Item = Result<VirtioGpuEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioGpuEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioGpuEvent {
OnConfigChanged {},
}
impl VirtioGpuEvent {
#[allow(irrefutable_let_patterns)]
pub fn into_on_config_changed(self) -> Option<()> {
if let VirtioGpuEvent::OnConfigChanged {} = self {
Some(())
} else {
None
}
}
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioGpuEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
0x1555f5b7c8444aa0 => {
let mut out = fidl::new_empty!(
fidl::encoding::EmptyPayload,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
Ok((VirtioGpuEvent::OnConfigChanged {}))
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioGpuRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioGpuRequestStream {}
impl futures::stream::FusedStream for VirtioGpuRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioGpuRequestStream {
type Protocol = VirtioGpuMarker;
type ControlHandle = VirtioGpuControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioGpuControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioGpuRequestStream {
type Item = Result<VirtioGpuRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioGpuRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
Ok(VirtioGpuRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioGpuConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
Ok(VirtioGpuRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
Ok(VirtioGpuRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioGpuReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x7e81ed410f770c14 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioGpuStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioGpuStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioGpuControlHandle { inner: this.inner.clone() };
Ok(VirtioGpuRequest::Start {
start_info: req.start_info,
keyboard_listener: req.keyboard_listener,
mouse_source: req.mouse_source,
responder: VirtioGpuStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <VirtioGpuMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioGpuRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioGpuConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioGpuControlHandle },
Ready { negotiated_features: u32, responder: VirtioGpuReadyResponder },
Start {
start_info: StartInfo,
keyboard_listener:
Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
mouse_source:
Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
responder: VirtioGpuStartResponder,
},
}
impl VirtioGpuRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioGpuConfigureQueueResponder)> {
if let VirtioGpuRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioGpuControlHandle)> {
if let VirtioGpuRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioGpuReadyResponder)> {
if let VirtioGpuRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(
self,
) -> Option<(
StartInfo,
Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_input3::KeyboardListenerMarker>>,
Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
VirtioGpuStartResponder,
)> {
if let VirtioGpuRequest::Start { start_info, keyboard_listener, mouse_source, responder } =
self
{
Some((start_info, keyboard_listener, mouse_source, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioGpuRequest::ConfigureQueue { .. } => "configure_queue",
VirtioGpuRequest::NotifyQueue { .. } => "notify_queue",
VirtioGpuRequest::Ready { .. } => "ready",
VirtioGpuRequest::Start { .. } => "start",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioGpuControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioGpuControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioGpuControlHandle {
pub fn send_on_config_changed(&self) -> Result<(), fidl::Error> {
self.inner.send::<fidl::encoding::EmptyPayload>(
(),
0,
0x1555f5b7c8444aa0,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioGpuConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioGpuConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioGpuConfigureQueueResponder {
type ControlHandle = VirtioGpuControlHandle;
fn control_handle(&self) -> &VirtioGpuControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioGpuConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioGpuReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioGpuReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioGpuReadyResponder {
type ControlHandle = VirtioGpuControlHandle;
fn control_handle(&self) -> &VirtioGpuControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioGpuReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioGpuStartResponder {
control_handle: std::mem::ManuallyDrop<VirtioGpuControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioGpuStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioGpuStartResponder {
type ControlHandle = VirtioGpuControlHandle;
fn control_handle(&self) -> &VirtioGpuControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioGpuStartResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x7e81ed410f770c14,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioInputMarker;
impl fidl::endpoints::ProtocolMarker for VirtioInputMarker {
type Proxy = VirtioInputProxy;
type RequestStream = VirtioInputRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioInputSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioInput";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioInputMarker {}
pub trait VirtioInputProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#start(&self, start_info: StartInfo, input_type: InputType) -> Self::StartResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioInputSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioInputSynchronousProxy {
type Proxy = VirtioInputProxy;
type Protocol = VirtioInputMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioInputSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioInputEvent, fidl::Error> {
VirtioInputEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut input_type: InputType,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioInputStartRequest, fidl::encoding::EmptyPayload>(
(&mut start_info, &mut input_type),
0x612743931f7f9249,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct VirtioInputProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioInputProxy {
type Protocol = VirtioInputMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioInputProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioInputEventStream {
VirtioInputEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioInputProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioInputProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioInputProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut input_type: InputType,
) -> fidl::client::QueryResponseFut<()> {
VirtioInputProxyInterface::r#start(self, start_info, input_type)
}
}
impl VirtioInputProxyInterface for VirtioInputProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<()>;
fn r#start(
&self,
mut start_info: StartInfo,
mut input_type: InputType,
) -> Self::StartResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x612743931f7f9249,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioInputStartRequest, ()>(
(&mut start_info, &mut input_type),
0x612743931f7f9249,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioInputEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioInputEventStream {}
impl futures::stream::FusedStream for VirtioInputEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioInputEventStream {
type Item = Result<VirtioInputEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioInputEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioInputEvent {}
impl VirtioInputEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioInputEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioInputRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioInputRequestStream {}
impl futures::stream::FusedStream for VirtioInputRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioInputRequestStream {
type Protocol = VirtioInputMarker;
type ControlHandle = VirtioInputControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioInputControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioInputRequestStream {
type Item = Result<VirtioInputRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioInputRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
Ok(VirtioInputRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioInputConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
Ok(VirtioInputRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
Ok(VirtioInputRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioInputReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x612743931f7f9249 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioInputStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioInputStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioInputControlHandle { inner: this.inner.clone() };
Ok(VirtioInputRequest::Start {
start_info: req.start_info,
input_type: req.input_type,
responder: VirtioInputStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<VirtioInputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioInputRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioInputConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioInputControlHandle },
Ready { negotiated_features: u32, responder: VirtioInputReadyResponder },
Start { start_info: StartInfo, input_type: InputType, responder: VirtioInputStartResponder },
}
impl VirtioInputRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioInputConfigureQueueResponder)> {
if let VirtioInputRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioInputControlHandle)> {
if let VirtioInputRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioInputReadyResponder)> {
if let VirtioInputRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(self) -> Option<(StartInfo, InputType, VirtioInputStartResponder)> {
if let VirtioInputRequest::Start { start_info, input_type, responder } = self {
Some((start_info, input_type, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioInputRequest::ConfigureQueue { .. } => "configure_queue",
VirtioInputRequest::NotifyQueue { .. } => "notify_queue",
VirtioInputRequest::Ready { .. } => "ready",
VirtioInputRequest::Start { .. } => "start",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioInputControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioInputControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioInputControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioInputConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioInputConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioInputConfigureQueueResponder {
type ControlHandle = VirtioInputControlHandle;
fn control_handle(&self) -> &VirtioInputControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioInputConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioInputReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioInputReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioInputReadyResponder {
type ControlHandle = VirtioInputControlHandle;
fn control_handle(&self) -> &VirtioInputControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioInputReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioInputStartResponder {
control_handle: std::mem::ManuallyDrop<VirtioInputControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioInputStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioInputStartResponder {
type ControlHandle = VirtioInputControlHandle;
fn control_handle(&self) -> &VirtioInputControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioInputStartResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x612743931f7f9249,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioMagmaMarker;
impl fidl::endpoints::ProtocolMarker for VirtioMagmaMarker {
type Proxy = VirtioMagmaProxy;
type RequestStream = VirtioMagmaRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioMagmaSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioMagma";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioMagmaMarker {}
pub trait VirtioMagmaProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
fn r#start(
&self,
start_info: StartInfo,
vmar: fidl::Vmar,
wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
) -> Self::StartResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioMagmaSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioMagmaSynchronousProxy {
type Proxy = VirtioMagmaProxy;
type Protocol = VirtioMagmaMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioMagmaSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioMagmaEvent, fidl::Error> {
VirtioMagmaEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut vmar: fidl::Vmar,
mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
___deadline: zx::MonotonicInstant,
) -> Result<i32, fidl::Error> {
let _response =
self.client.send_query::<VirtioMagmaStartRequest, VirtioMagmaStartResponse>(
(&mut start_info, vmar, wayland_importer),
0x6b94e28f73d201e2,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.status)
}
}
#[derive(Debug, Clone)]
pub struct VirtioMagmaProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioMagmaProxy {
type Protocol = VirtioMagmaMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioMagmaProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioMagmaEventStream {
VirtioMagmaEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioMagmaProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioMagmaProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioMagmaProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut vmar: fidl::Vmar,
mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
) -> fidl::client::QueryResponseFut<i32> {
VirtioMagmaProxyInterface::r#start(self, start_info, vmar, wayland_importer)
}
}
impl VirtioMagmaProxyInterface for VirtioMagmaProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<i32>;
fn r#start(
&self,
mut start_info: StartInfo,
mut vmar: fidl::Vmar,
mut wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
) -> Self::StartResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<i32, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
VirtioMagmaStartResponse,
0x6b94e28f73d201e2,
>(_buf?)?;
Ok(_response.status)
}
self.client.send_query_and_decode::<VirtioMagmaStartRequest, i32>(
(&mut start_info, vmar, wayland_importer),
0x6b94e28f73d201e2,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioMagmaEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioMagmaEventStream {}
impl futures::stream::FusedStream for VirtioMagmaEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioMagmaEventStream {
type Item = Result<VirtioMagmaEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioMagmaEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioMagmaEvent {}
impl VirtioMagmaEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioMagmaEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioMagmaRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioMagmaRequestStream {}
impl futures::stream::FusedStream for VirtioMagmaRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioMagmaRequestStream {
type Protocol = VirtioMagmaMarker;
type ControlHandle = VirtioMagmaControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioMagmaControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioMagmaRequestStream {
type Item = Result<VirtioMagmaRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioMagmaRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
Ok(VirtioMagmaRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioMagmaConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
Ok(VirtioMagmaRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
Ok(VirtioMagmaRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioMagmaReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6b94e28f73d201e2 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioMagmaStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMagmaStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioMagmaControlHandle { inner: this.inner.clone() };
Ok(VirtioMagmaRequest::Start {
start_info: req.start_info,
vmar: req.vmar,
wayland_importer: req.wayland_importer,
responder: VirtioMagmaStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<VirtioMagmaMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioMagmaRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioMagmaConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioMagmaControlHandle },
Ready { negotiated_features: u32, responder: VirtioMagmaReadyResponder },
Start {
start_info: StartInfo,
vmar: fidl::Vmar,
wayland_importer: Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
responder: VirtioMagmaStartResponder,
},
}
impl VirtioMagmaRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioMagmaConfigureQueueResponder)> {
if let VirtioMagmaRequest::ConfigureQueue { queue, size, desc, avail, used, responder } =
self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioMagmaControlHandle)> {
if let VirtioMagmaRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioMagmaReadyResponder)> {
if let VirtioMagmaRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(
self,
) -> Option<(
StartInfo,
fidl::Vmar,
Option<fidl::endpoints::ClientEnd<VirtioWaylandImporterMarker>>,
VirtioMagmaStartResponder,
)> {
if let VirtioMagmaRequest::Start { start_info, vmar, wayland_importer, responder } = self {
Some((start_info, vmar, wayland_importer, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioMagmaRequest::ConfigureQueue { .. } => "configure_queue",
VirtioMagmaRequest::NotifyQueue { .. } => "notify_queue",
VirtioMagmaRequest::Ready { .. } => "ready",
VirtioMagmaRequest::Start { .. } => "start",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioMagmaControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioMagmaControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioMagmaControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioMagmaConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioMagmaConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioMagmaConfigureQueueResponder {
type ControlHandle = VirtioMagmaControlHandle;
fn control_handle(&self) -> &VirtioMagmaControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioMagmaConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioMagmaReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioMagmaReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioMagmaReadyResponder {
type ControlHandle = VirtioMagmaControlHandle;
fn control_handle(&self) -> &VirtioMagmaControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioMagmaReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioMagmaStartResponder {
control_handle: std::mem::ManuallyDrop<VirtioMagmaControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioMagmaStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioMagmaStartResponder {
type ControlHandle = VirtioMagmaControlHandle;
fn control_handle(&self) -> &VirtioMagmaControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioMagmaStartResponder {
pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
let _result = self.send_raw(status);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
let _result = self.send_raw(status);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<VirtioMagmaStartResponse>(
(status,),
self.tx_id,
0x6b94e28f73d201e2,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioMemMarker;
impl fidl::endpoints::ProtocolMarker for VirtioMemMarker {
type Proxy = VirtioMemProxy;
type RequestStream = VirtioMemRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioMemSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioMem";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioMemMarker {}
pub trait VirtioMemProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#start(
&self,
start_info: StartInfo,
region_addr: u64,
plugged_block_size: u64,
region_size: u64,
) -> Self::StartResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioMemSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioMemSynchronousProxy {
type Proxy = VirtioMemProxy;
type Protocol = VirtioMemMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioMemSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioMemEvent, fidl::Error> {
VirtioMemEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut region_addr: u64,
mut plugged_block_size: u64,
mut region_size: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioMemStartRequest, fidl::encoding::EmptyPayload>(
(&mut start_info, region_addr, plugged_block_size, region_size),
0x66dd64f17fb5223c,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct VirtioMemProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioMemProxy {
type Protocol = VirtioMemMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioMemProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioMemEventStream {
VirtioMemEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioMemProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioMemProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioMemProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut region_addr: u64,
mut plugged_block_size: u64,
mut region_size: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioMemProxyInterface::r#start(
self,
start_info,
region_addr,
plugged_block_size,
region_size,
)
}
}
impl VirtioMemProxyInterface for VirtioMemProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<()>;
fn r#start(
&self,
mut start_info: StartInfo,
mut region_addr: u64,
mut plugged_block_size: u64,
mut region_size: u64,
) -> Self::StartResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x66dd64f17fb5223c,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioMemStartRequest, ()>(
(&mut start_info, region_addr, plugged_block_size, region_size),
0x66dd64f17fb5223c,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioMemEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioMemEventStream {}
impl futures::stream::FusedStream for VirtioMemEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioMemEventStream {
type Item = Result<VirtioMemEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioMemEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioMemEvent {
OnConfigChanged { plugged_size: u64 },
}
impl VirtioMemEvent {
#[allow(irrefutable_let_patterns)]
pub fn into_on_config_changed(self) -> Option<u64> {
if let VirtioMemEvent::OnConfigChanged { plugged_size } = self {
Some((plugged_size))
} else {
None
}
}
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioMemEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
0x73b86d7cc80020b9 => {
let mut out = fidl::new_empty!(
VirtioMemOnConfigChangedRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMemOnConfigChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
Ok((VirtioMemEvent::OnConfigChanged { plugged_size: out.plugged_size }))
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioMemRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioMemRequestStream {}
impl futures::stream::FusedStream for VirtioMemRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioMemRequestStream {
type Protocol = VirtioMemMarker;
type ControlHandle = VirtioMemControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioMemControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioMemRequestStream {
type Item = Result<VirtioMemRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioMemRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
Ok(VirtioMemRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioMemConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
Ok(VirtioMemRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
Ok(VirtioMemRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioMemReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x66dd64f17fb5223c => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioMemStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioMemStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioMemControlHandle { inner: this.inner.clone() };
Ok(VirtioMemRequest::Start {
start_info: req.start_info,
region_addr: req.region_addr,
plugged_block_size: req.plugged_block_size,
region_size: req.region_size,
responder: VirtioMemStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <VirtioMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioMemRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioMemConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioMemControlHandle },
Ready { negotiated_features: u32, responder: VirtioMemReadyResponder },
Start {
start_info: StartInfo,
region_addr: u64,
plugged_block_size: u64,
region_size: u64,
responder: VirtioMemStartResponder,
},
}
impl VirtioMemRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioMemConfigureQueueResponder)> {
if let VirtioMemRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioMemControlHandle)> {
if let VirtioMemRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioMemReadyResponder)> {
if let VirtioMemRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(self) -> Option<(StartInfo, u64, u64, u64, VirtioMemStartResponder)> {
if let VirtioMemRequest::Start {
start_info,
region_addr,
plugged_block_size,
region_size,
responder,
} = self
{
Some((start_info, region_addr, plugged_block_size, region_size, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioMemRequest::ConfigureQueue { .. } => "configure_queue",
VirtioMemRequest::NotifyQueue { .. } => "notify_queue",
VirtioMemRequest::Ready { .. } => "ready",
VirtioMemRequest::Start { .. } => "start",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioMemControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioMemControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioMemControlHandle {
pub fn send_on_config_changed(&self, mut plugged_size: u64) -> Result<(), fidl::Error> {
self.inner.send::<VirtioMemOnConfigChangedRequest>(
(plugged_size,),
0,
0x73b86d7cc80020b9,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioMemConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioMemConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioMemConfigureQueueResponder {
type ControlHandle = VirtioMemControlHandle;
fn control_handle(&self) -> &VirtioMemControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioMemConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioMemReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioMemReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioMemReadyResponder {
type ControlHandle = VirtioMemControlHandle;
fn control_handle(&self) -> &VirtioMemControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioMemReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioMemStartResponder {
control_handle: std::mem::ManuallyDrop<VirtioMemControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioMemStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioMemStartResponder {
type ControlHandle = VirtioMemControlHandle;
fn control_handle(&self) -> &VirtioMemControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioMemStartResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x66dd64f17fb5223c,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioNetMarker;
impl fidl::endpoints::ProtocolMarker for VirtioNetMarker {
type Proxy = VirtioNetProxy;
type RequestStream = VirtioNetRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioNetSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioNet";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioNetMarker {}
pub type VirtioNetStartResult = Result<(), i32>;
pub trait VirtioNetProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<VirtioNetStartResult, fidl::Error>>
+ Send;
fn r#start(
&self,
start_info: StartInfo,
mac_address: &fidl_fuchsia_net::MacAddress,
enable_bridge: bool,
) -> Self::StartResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioNetSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioNetSynchronousProxy {
type Proxy = VirtioNetProxy;
type Protocol = VirtioNetMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioNetSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioNetEvent, fidl::Error> {
VirtioNetEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut mac_address: &fidl_fuchsia_net::MacAddress,
mut enable_bridge: bool,
___deadline: zx::MonotonicInstant,
) -> Result<VirtioNetStartResult, fidl::Error> {
let _response = self.client.send_query::<
VirtioNetStartRequest,
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
>(
(&mut start_info, mac_address, enable_bridge,),
0x795c0b3a8461b3ed,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x))
}
}
#[derive(Debug, Clone)]
pub struct VirtioNetProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioNetProxy {
type Protocol = VirtioNetMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioNetProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioNetEventStream {
VirtioNetEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioNetProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioNetProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioNetProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
mut mac_address: &fidl_fuchsia_net::MacAddress,
mut enable_bridge: bool,
) -> fidl::client::QueryResponseFut<VirtioNetStartResult> {
VirtioNetProxyInterface::r#start(self, start_info, mac_address, enable_bridge)
}
}
impl VirtioNetProxyInterface for VirtioNetProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<VirtioNetStartResult>;
fn r#start(
&self,
mut start_info: StartInfo,
mut mac_address: &fidl_fuchsia_net::MacAddress,
mut enable_bridge: bool,
) -> Self::StartResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<VirtioNetStartResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
0x795c0b3a8461b3ed,
>(_buf?)?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<VirtioNetStartRequest, VirtioNetStartResult>(
(&mut start_info, mac_address, enable_bridge),
0x795c0b3a8461b3ed,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioNetEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioNetEventStream {}
impl futures::stream::FusedStream for VirtioNetEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioNetEventStream {
type Item = Result<VirtioNetEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioNetEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioNetEvent {}
impl VirtioNetEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioNetEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioNetRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioNetRequestStream {}
impl futures::stream::FusedStream for VirtioNetRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioNetRequestStream {
type Protocol = VirtioNetMarker;
type ControlHandle = VirtioNetControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioNetControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioNetRequestStream {
type Item = Result<VirtioNetRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioNetRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
Ok(VirtioNetRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioNetConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
Ok(VirtioNetRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
Ok(VirtioNetRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioNetReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x795c0b3a8461b3ed => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioNetStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioNetStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioNetControlHandle { inner: this.inner.clone() };
Ok(VirtioNetRequest::Start {
start_info: req.start_info,
mac_address: req.mac_address,
enable_bridge: req.enable_bridge,
responder: VirtioNetStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <VirtioNetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioNetRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioNetConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioNetControlHandle },
Ready { negotiated_features: u32, responder: VirtioNetReadyResponder },
Start {
start_info: StartInfo,
mac_address: fidl_fuchsia_net::MacAddress,
enable_bridge: bool,
responder: VirtioNetStartResponder,
},
}
impl VirtioNetRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioNetConfigureQueueResponder)> {
if let VirtioNetRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioNetControlHandle)> {
if let VirtioNetRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioNetReadyResponder)> {
if let VirtioNetRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(
self,
) -> Option<(StartInfo, fidl_fuchsia_net::MacAddress, bool, VirtioNetStartResponder)> {
if let VirtioNetRequest::Start { start_info, mac_address, enable_bridge, responder } = self
{
Some((start_info, mac_address, enable_bridge, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioNetRequest::ConfigureQueue { .. } => "configure_queue",
VirtioNetRequest::NotifyQueue { .. } => "notify_queue",
VirtioNetRequest::Ready { .. } => "ready",
VirtioNetRequest::Start { .. } => "start",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioNetControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioNetControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioNetControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioNetConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioNetConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioNetConfigureQueueResponder {
type ControlHandle = VirtioNetControlHandle;
fn control_handle(&self) -> &VirtioNetControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioNetConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioNetReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioNetReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioNetReadyResponder {
type ControlHandle = VirtioNetControlHandle;
fn control_handle(&self) -> &VirtioNetControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioNetReadyResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioNetStartResponder {
control_handle: std::mem::ManuallyDrop<VirtioNetControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioNetStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioNetStartResponder {
type ControlHandle = VirtioNetControlHandle;
fn control_handle(&self) -> &VirtioNetControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioNetStartResponder {
pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
self.control_handle
.inner
.send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
result,
self.tx_id,
0x795c0b3a8461b3ed,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtioRngMarker;
impl fidl::endpoints::ProtocolMarker for VirtioRngMarker {
type Proxy = VirtioRngProxy;
type RequestStream = VirtioRngRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = VirtioRngSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.virtualization.hardware.VirtioRng";
}
impl fidl::endpoints::DiscoverableProtocolMarker for VirtioRngMarker {}
pub trait VirtioRngProxyInterface: Send + Sync {
type ConfigureQueueResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#configure_queue(
&self,
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
) -> Self::ConfigureQueueResponseFut;
fn r#notify_queue(&self, queue: u16) -> Result<(), fidl::Error>;
type ReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#ready(&self, negotiated_features: u32) -> Self::ReadyResponseFut;
type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#start(&self, start_info: StartInfo) -> Self::StartResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct VirtioRngSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for VirtioRngSynchronousProxy {
type Proxy = VirtioRngProxy;
type Protocol = VirtioRngMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl VirtioRngSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<VirtioRngEvent, fidl::Error> {
VirtioRngEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<VirtioDeviceConfigureQueueRequest, fidl::encoding::EmptyPayload>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#ready(
&self,
mut negotiated_features: u32,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioDeviceReadyRequest, fidl::encoding::EmptyPayload>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#start(
&self,
mut start_info: StartInfo,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<VirtioRngStartRequest, fidl::encoding::EmptyPayload>(
(&mut start_info,),
0x620b3ed254febc0f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct VirtioRngProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for VirtioRngProxy {
type Protocol = VirtioRngMarker;
fn from_channel(inner: fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl VirtioRngProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> VirtioRngEventStream {
VirtioRngEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> fidl::client::QueryResponseFut<()> {
VirtioRngProxyInterface::r#configure_queue(self, queue, size, desc, avail, used)
}
pub fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
VirtioRngProxyInterface::r#notify_queue(self, queue)
}
pub fn r#ready(&self, mut negotiated_features: u32) -> fidl::client::QueryResponseFut<()> {
VirtioRngProxyInterface::r#ready(self, negotiated_features)
}
pub fn r#start(&self, mut start_info: StartInfo) -> fidl::client::QueryResponseFut<()> {
VirtioRngProxyInterface::r#start(self, start_info)
}
}
impl VirtioRngProxyInterface for VirtioRngProxy {
type ConfigureQueueResponseFut = fidl::client::QueryResponseFut<()>;
fn r#configure_queue(
&self,
mut queue: u16,
mut size: u16,
mut desc: u64,
mut avail: u64,
mut used: u64,
) -> Self::ConfigureQueueResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x72b44fb963480b11,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceConfigureQueueRequest, ()>(
(queue, size, desc, avail, used),
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#notify_queue(&self, mut queue: u16) -> Result<(), fidl::Error> {
self.client.send::<VirtioDeviceNotifyQueueRequest>(
(queue,),
0x6e3a61d652499244,
fidl::encoding::DynamicFlags::empty(),
)
}
type ReadyResponseFut = fidl::client::QueryResponseFut<()>;
fn r#ready(&self, mut negotiated_features: u32) -> Self::ReadyResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x45707654f5d23c3f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioDeviceReadyRequest, ()>(
(negotiated_features,),
0x45707654f5d23c3f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartResponseFut = fidl::client::QueryResponseFut<()>;
fn r#start(&self, mut start_info: StartInfo) -> Self::StartResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x620b3ed254febc0f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<VirtioRngStartRequest, ()>(
(&mut start_info,),
0x620b3ed254febc0f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct VirtioRngEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for VirtioRngEventStream {}
impl futures::stream::FusedStream for VirtioRngEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for VirtioRngEventStream {
type Item = Result<VirtioRngEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(VirtioRngEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum VirtioRngEvent {}
impl VirtioRngEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<VirtioRngEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct VirtioRngRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for VirtioRngRequestStream {}
impl futures::stream::FusedStream for VirtioRngRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for VirtioRngRequestStream {
type Protocol = VirtioRngMarker;
type ControlHandle = VirtioRngControlHandle;
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
VirtioRngControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for VirtioRngRequestStream {
type Item = Result<VirtioRngRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled VirtioRngRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x72b44fb963480b11 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceConfigureQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceConfigureQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
Ok(VirtioRngRequest::ConfigureQueue {
queue: req.queue,
size: req.size,
desc: req.desc,
avail: req.avail,
used: req.used,
responder: VirtioRngConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6e3a61d652499244 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceNotifyQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceNotifyQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
Ok(VirtioRngRequest::NotifyQueue { queue: req.queue, control_handle })
}
0x45707654f5d23c3f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioDeviceReadyRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioDeviceReadyRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
Ok(VirtioRngRequest::Ready {
negotiated_features: req.negotiated_features,
responder: VirtioRngReadyResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x620b3ed254febc0f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
VirtioRngStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtioRngStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = VirtioRngControlHandle { inner: this.inner.clone() };
Ok(VirtioRngRequest::Start {
start_info: req.start_info,
responder: VirtioRngStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <VirtioRngMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum VirtioRngRequest {
ConfigureQueue {
queue: u16,
size: u16,
desc: u64,
avail: u64,
used: u64,
responder: VirtioRngConfigureQueueResponder,
},
NotifyQueue { queue: u16, control_handle: VirtioRngControlHandle },
Ready { negotiated_features: u32, responder: VirtioRngReadyResponder },
Start { start_info: StartInfo, responder: VirtioRngStartResponder },
}
impl VirtioRngRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_queue(
self,
) -> Option<(u16, u16, u64, u64, u64, VirtioRngConfigureQueueResponder)> {
if let VirtioRngRequest::ConfigureQueue { queue, size, desc, avail, used, responder } = self
{
Some((queue, size, desc, avail, used, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_notify_queue(self) -> Option<(u16, VirtioRngControlHandle)> {
if let VirtioRngRequest::NotifyQueue { queue, control_handle } = self {
Some((queue, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_ready(self) -> Option<(u32, VirtioRngReadyResponder)> {
if let VirtioRngRequest::Ready { negotiated_features, responder } = self {
Some((negotiated_features, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start(self) -> Option<(StartInfo, VirtioRngStartResponder)> {
if let VirtioRngRequest::Start { start_info, responder } = self {
Some((start_info, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
VirtioRngRequest::ConfigureQueue { .. } => "configure_queue",
VirtioRngRequest::NotifyQueue { .. } => "notify_queue",
VirtioRngRequest::Ready { .. } => "ready",
VirtioRngRequest::Start { .. } => "start",
}
}
}
#[derive(Debug, Clone)]
pub struct VirtioRngControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for VirtioRngControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().as_ref().signal_peer(clear_mask, set_mask)
}
}
impl VirtioRngControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioRngConfigureQueueResponder {
control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioRngConfigureQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioRngConfigureQueueResponder {
type ControlHandle = VirtioRngControlHandle;
fn control_handle(&self) -> &VirtioRngControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl VirtioRngConfigureQueueResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x72b44fb963480b11,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct VirtioRngReadyResponder {
control_handle: std::mem::ManuallyDrop<VirtioRngControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for VirtioRngReadyResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for VirtioRngReadyResponder {
type ControlHandle = VirtioRn