blob: a454173a5e42a1b5219c835d7b3510b4cfe4be78 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#![allow(
deprecated, // FIDL Impl struct pattern is referenced internally
unused_parens, // one-element-tuple-case is not a tuple
unused_mut, // not all args require mutation, but many do
nonstandard_style, // auto-caps does its best, but is not always successful
)]
#![recursion_limit = "512"]
#[cfg(target_os = "fuchsia")]
#[allow(unused_imports)]
use fuchsia_zircon as zx;
#[allow(unused_imports)]
use {
bitflags::bitflags,
fidl::{
client::{decode_transaction_body_fut, QueryResponseFut},
encoding::{Decodable as _, Encodable as _},
fidl_empty_struct, fidl_flexible_bits, fidl_flexible_enum, fidl_strict_bits,
fidl_strict_enum, fidl_struct, fidl_struct_copy, fidl_table, fidl_xunion,
wrap_handle_metadata,
},
fuchsia_zircon_status as zx_status,
futures::future::{self, MaybeDone, TryFutureExt},
};
const _FIDL_TRACE_BINDINGS_RUST: u32 = 6;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum ObjType {
None = 0,
Process = 1,
Thread = 2,
Vmo = 3,
Channel = 4,
Event = 5,
Port = 6,
Interrupt = 9,
PciDevice = 11,
Log = 12,
Socket = 14,
Resource = 15,
Eventpair = 16,
Job = 17,
Vmar = 18,
Fifo = 19,
Guest = 20,
Vcpu = 21,
Timer = 22,
Iommu = 23,
Bti = 24,
Profile = 25,
Pmt = 26,
SuspendToken = 27,
Pager = 28,
Exception = 29,
Clock = 30,
Stream = 31,
MsiAllocation = 32,
MsiInterrupt = 33,
}
fidl_strict_enum! {
name: ObjType,
prim_ty: u32,
members: [
None { value: 0, },
Process { value: 1, },
Thread { value: 2, },
Vmo { value: 3, },
Channel { value: 4, },
Event { value: 5, },
Port { value: 6, },
Interrupt { value: 9, },
PciDevice { value: 11, },
Log { value: 12, },
Socket { value: 14, },
Resource { value: 15, },
Eventpair { value: 16, },
Job { value: 17, },
Vmar { value: 18, },
Fifo { value: 19, },
Guest { value: 20, },
Vcpu { value: 21, },
Timer { value: 22, },
Iommu { value: 23, },
Bti { value: 24, },
Profile { value: 25, },
Pmt { value: 26, },
SuspendToken { value: 27, },
Pager { value: 28, },
Exception { value: 29, },
Clock { value: 30, },
Stream { value: 31, },
MsiAllocation { value: 32, },
MsiInterrupt { value: 33, },
],
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct Handles {
pub plain_handle: fidl::Handle,
pub bti_handle: fidl::Bti,
pub channel_handle: fidl::Channel,
pub clock_handle: fidl::Clock,
pub debuglog_handle: fidl::DebugLog,
pub event_handle: fidl::Event,
pub eventpair_handle: fidl::EventPair,
pub exception_handle: fidl::Exception,
pub fifo_handle: fidl::Fifo,
pub guest_handle: fidl::Guest,
pub interrupt_handle: fidl::Interrupt,
pub iommu_handle: fidl::Iommu,
pub job_handle: fidl::Job,
pub pager_handle: fidl::Pager,
pub pcidevice_handle: fidl::PciDevice,
pub pmt_handle: fidl::Pmt,
pub port_handle: fidl::Port,
pub process_handle: fidl::Process,
pub profile_handle: fidl::Profile,
pub resource_handle: fidl::Resource,
pub socket_handle: fidl::Socket,
pub suspendtoken_handle: fidl::SuspendToken,
pub thread_handle: fidl::Thread,
pub timer_handle: fidl::Timer,
pub vcpu_handle: fidl::Vcpu,
pub vmar_handle: fidl::Vmar,
pub vmo_handle: fidl::Vmo,
pub rights_handle: fidl::Vmo,
pub aliased_plain_handle_field: fidl::Handle,
pub aliased_subtype_handle_field: fidl::Vmo,
pub aliased_rights_handle_field: fidl::Vmo,
pub some_protocol: fidl::endpoints::ClientEnd<SomeProtocolMarker>,
pub request_some_protocol: fidl::endpoints::ServerEnd<SomeProtocolMarker>,
}
fidl_struct! {
name: Handles,
members: [
plain_handle {
ty: fidl::Handle,
offset_v1: 0,
handle_metadata: {
handle_subtype: fidl::ObjectType::NONE,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
bti_handle {
ty: fidl::Bti,
offset_v1: 4,
handle_metadata: {
handle_subtype: fidl::ObjectType::BTI,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
channel_handle {
ty: fidl::Channel,
offset_v1: 8,
handle_metadata: {
handle_subtype: fidl::ObjectType::CHANNEL,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
clock_handle {
ty: fidl::Clock,
offset_v1: 12,
handle_metadata: {
handle_subtype: fidl::ObjectType::CLOCK,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
debuglog_handle {
ty: fidl::DebugLog,
offset_v1: 16,
handle_metadata: {
handle_subtype: fidl::ObjectType::LOG,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
event_handle {
ty: fidl::Event,
offset_v1: 20,
handle_metadata: {
handle_subtype: fidl::ObjectType::EVENT,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
eventpair_handle {
ty: fidl::EventPair,
offset_v1: 24,
handle_metadata: {
handle_subtype: fidl::ObjectType::EVENTPAIR,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
exception_handle {
ty: fidl::Exception,
offset_v1: 28,
handle_metadata: {
handle_subtype: fidl::ObjectType::EXCEPTION,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
fifo_handle {
ty: fidl::Fifo,
offset_v1: 32,
handle_metadata: {
handle_subtype: fidl::ObjectType::FIFO,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
guest_handle {
ty: fidl::Guest,
offset_v1: 36,
handle_metadata: {
handle_subtype: fidl::ObjectType::GUEST,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
interrupt_handle {
ty: fidl::Interrupt,
offset_v1: 40,
handle_metadata: {
handle_subtype: fidl::ObjectType::INTERRUPT,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
iommu_handle {
ty: fidl::Iommu,
offset_v1: 44,
handle_metadata: {
handle_subtype: fidl::ObjectType::IOMMU,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
job_handle {
ty: fidl::Job,
offset_v1: 48,
handle_metadata: {
handle_subtype: fidl::ObjectType::JOB,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
pager_handle {
ty: fidl::Pager,
offset_v1: 52,
handle_metadata: {
handle_subtype: fidl::ObjectType::PAGER,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
pcidevice_handle {
ty: fidl::PciDevice,
offset_v1: 56,
handle_metadata: {
handle_subtype: fidl::ObjectType::PCI_DEVICE,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
pmt_handle {
ty: fidl::Pmt,
offset_v1: 60,
handle_metadata: {
handle_subtype: fidl::ObjectType::PMT,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
port_handle {
ty: fidl::Port,
offset_v1: 64,
handle_metadata: {
handle_subtype: fidl::ObjectType::PORT,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
process_handle {
ty: fidl::Process,
offset_v1: 68,
handle_metadata: {
handle_subtype: fidl::ObjectType::PROCESS,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
profile_handle {
ty: fidl::Profile,
offset_v1: 72,
handle_metadata: {
handle_subtype: fidl::ObjectType::PROFILE,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
resource_handle {
ty: fidl::Resource,
offset_v1: 76,
handle_metadata: {
handle_subtype: fidl::ObjectType::RESOURCE,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
socket_handle {
ty: fidl::Socket,
offset_v1: 80,
handle_metadata: {
handle_subtype: fidl::ObjectType::SOCKET,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
suspendtoken_handle {
ty: fidl::SuspendToken,
offset_v1: 84,
handle_metadata: {
handle_subtype: fidl::ObjectType::SUSPEND_TOKEN,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
thread_handle {
ty: fidl::Thread,
offset_v1: 88,
handle_metadata: {
handle_subtype: fidl::ObjectType::THREAD,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
timer_handle {
ty: fidl::Timer,
offset_v1: 92,
handle_metadata: {
handle_subtype: fidl::ObjectType::TIMER,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
vcpu_handle {
ty: fidl::Vcpu,
offset_v1: 96,
handle_metadata: {
handle_subtype: fidl::ObjectType::VCPU,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
vmar_handle {
ty: fidl::Vmar,
offset_v1: 100,
handle_metadata: {
handle_subtype: fidl::ObjectType::VMAR,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
vmo_handle {
ty: fidl::Vmo,
offset_v1: 104,
handle_metadata: {
handle_subtype: fidl::ObjectType::VMO,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
rights_handle {
ty: fidl::Vmo,
offset_v1: 108,
handle_metadata: {
handle_subtype: fidl::ObjectType::VMO,
handle_rights: fidl::Rights::from_bits_const(5).unwrap(),
},
},
aliased_plain_handle_field {
ty: fidl::Handle,
offset_v1: 112,
handle_metadata: {
handle_subtype: fidl::ObjectType::NONE,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
aliased_subtype_handle_field {
ty: fidl::Vmo,
offset_v1: 116,
handle_metadata: {
handle_subtype: fidl::ObjectType::VMO,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
aliased_rights_handle_field {
ty: fidl::Vmo,
offset_v1: 120,
handle_metadata: {
handle_subtype: fidl::ObjectType::VMO,
handle_rights: fidl::Rights::from_bits_const(1).unwrap(),
},
},
some_protocol {
ty: fidl::endpoints::ClientEnd<SomeProtocolMarker>,
offset_v1: 124,
handle_metadata: {
handle_subtype: fidl::ObjectType::CHANNEL,
handle_rights: fidl::Rights::CHANNEL_DEFAULT,
},
},
request_some_protocol {
ty: fidl::endpoints::ServerEnd<SomeProtocolMarker>,
offset_v1: 128,
handle_metadata: {
handle_subtype: fidl::ObjectType::CHANNEL,
handle_rights: fidl::Rights::CHANNEL_DEFAULT,
},
},
],
padding: [],
size_v1: 132,
align_v1: 4,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct SomeProtocolMarker;
impl fidl::endpoints::ServiceMarker for SomeProtocolMarker {
type Proxy = SomeProtocolProxy;
type RequestStream = SomeProtocolRequestStream;
const DEBUG_NAME: &'static str = "(anonymous) SomeProtocol";
}
pub trait SomeProtocolProxyInterface: Send + Sync {}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct SomeProtocolSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl SomeProtocolSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let service_name = <SomeProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, service_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
}
#[derive(Debug, Clone)]
pub struct SomeProtocolProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for SomeProtocolProxy {
type Service = SomeProtocolMarker;
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 SomeProtocolProxy {
/// Create a new Proxy for SomeProtocol
pub fn new(channel: fidl::AsyncChannel) -> Self {
let service_name = <SomeProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, service_name) }
}
/// Get a Stream of events from the remote end of the SomeProtocol protocol
///
/// # Panics
///
/// Panics if the event stream was already taken.
pub fn take_event_stream(&self) -> SomeProtocolEventStream {
SomeProtocolEventStream { event_receiver: self.client.take_event_receiver() }
}
}
impl SomeProtocolProxyInterface for SomeProtocolProxy {}
pub struct SomeProtocolEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for SomeProtocolEventStream {}
impl futures::stream::FusedStream for SomeProtocolEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for SomeProtocolEventStream {
type Item = Result<SomeProtocolEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let mut buf = match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => buf,
None => return std::task::Poll::Ready(None),
};
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match tx_header.ordinal() {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal(),
service_name: <SomeProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME,
}),
}))
}
}
#[derive(Debug)]
pub enum SomeProtocolEvent {}
impl SomeProtocolEvent {}
/// A type which can be used to send responses and events into a borrowed channel.
///
/// Note: this should only be used when the channel must be temporarily
/// borrowed. For a typical sending of events, use the send_ methods
/// on the ControlHandle types, which can be acquired through a
/// RequestStream or Responder type.
#[deprecated(note = "Use SomeProtocolRequestStream / Responder instead")]
pub struct SomeProtocolServerSender<'a> {
// Some protocols don't define events which would render this channel unused.
#[allow(unused)]
channel: &'a fidl::Channel,
}
impl<'a> SomeProtocolServerSender<'a> {
pub fn new(channel: &'a fidl::Channel) -> Self {
Self { channel }
}
}
/// A Stream of incoming requests for SomeProtocol
pub struct SomeProtocolRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for SomeProtocolRequestStream {}
impl futures::stream::FusedStream for SomeProtocolRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for SomeProtocolRequestStream {
type Service = SomeProtocolMarker;
/// Consume a channel to make a SomeProtocolRequestStream
fn from_channel(channel: fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
/// ControlHandle for the remote connection
type ControlHandle = SomeProtocolControlHandle;
/// ControlHandle for the remote connection
fn control_handle(&self) -> Self::ControlHandle {
SomeProtocolControlHandle { 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 SomeProtocolRequestStream {
type Item = Result<SomeProtocolRequest, 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.poll_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled SomeProtocolRequestStream 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))))
}
}
// A message has been received from the channel
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
if !header.is_compatible() {
return std::task::Poll::Ready(Some(Err(fidl::Error::IncompatibleMagicNumber(
header.magic_number(),
))));
}
std::task::Poll::Ready(Some(match header.ordinal() {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal(),
service_name:
<SomeProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME,
}),
}))
})
}
}
/// Represents a single request.
/// RequestMessages should only be used for manual deserialization when higher level
/// structs such as RequestStream cannot be used. One usually would only encounter
/// such scenarios when working with legacy FIDL code (prior to FIDL generated client/server bindings).
#[derive(Debug)]
#[deprecated(note = "Use SomeProtocolRequest instead")]
pub enum SomeProtocolRequestMessage {}
impl SomeProtocolRequestMessage {
pub fn decode(
bytes: &[u8],
_handles: &mut [fidl::HandleInfo],
) -> Result<SomeProtocolRequestMessage, fidl::Error> {
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
match header.ordinal() {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal(),
service_name: <SomeProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME,
}),
}
}
}
#[derive(Debug)]
pub enum SomeProtocolRequest {}
impl SomeProtocolRequest {
/// Name of the method defined in FIDL
pub fn method_name(&self) -> &'static str {
match *self {}
}
}
pub struct SomeProtocolEncoder;
impl SomeProtocolEncoder {}
#[derive(Debug, Clone)]
pub struct SomeProtocolControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl SomeProtocolControlHandle {
/// Set the server to shutdown. The underlying channel is only closed the
/// next time the stream is polled.
pub fn shutdown(&self) {
self.inner.shutdown()
}
pub fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
}