blob: f0a02acd8ffcc80b3c22472d3fa0384dc9411bb7 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#![allow(
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 _},
endpoints::{ControlHandle as _, Responder as _},
fidl_bits, fidl_empty_struct, fidl_enum, fidl_struct, fidl_struct_copy, fidl_table,
fidl_union, wrap_handle_metadata,
},
fuchsia_zircon_status as zx_status,
futures::future::{self, MaybeDone, TryFutureExt},
};
const _FIDL_TRACE_BINDINGS_RUST: u32 = 6;
#[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 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 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,
offset_v2: 52,
handle_metadata: {
handle_subtype: fidl::ObjectType::PAGER,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
pmt_handle {
ty: fidl::Pmt,
offset_v1: 56,
offset_v2: 56,
handle_metadata: {
handle_subtype: fidl::ObjectType::PMT,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
port_handle {
ty: fidl::Port,
offset_v1: 60,
offset_v2: 60,
handle_metadata: {
handle_subtype: fidl::ObjectType::PORT,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
process_handle {
ty: fidl::Process,
offset_v1: 64,
offset_v2: 64,
handle_metadata: {
handle_subtype: fidl::ObjectType::PROCESS,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
profile_handle {
ty: fidl::Profile,
offset_v1: 68,
offset_v2: 68,
handle_metadata: {
handle_subtype: fidl::ObjectType::PROFILE,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
resource_handle {
ty: fidl::Resource,
offset_v1: 72,
offset_v2: 72,
handle_metadata: {
handle_subtype: fidl::ObjectType::RESOURCE,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
socket_handle {
ty: fidl::Socket,
offset_v1: 76,
offset_v2: 76,
handle_metadata: {
handle_subtype: fidl::ObjectType::SOCKET,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
suspendtoken_handle {
ty: fidl::SuspendToken,
offset_v1: 80,
offset_v2: 80,
handle_metadata: {
handle_subtype: fidl::ObjectType::SUSPEND_TOKEN,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
thread_handle {
ty: fidl::Thread,
offset_v1: 84,
offset_v2: 84,
handle_metadata: {
handle_subtype: fidl::ObjectType::THREAD,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
timer_handle {
ty: fidl::Timer,
offset_v1: 88,
offset_v2: 88,
handle_metadata: {
handle_subtype: fidl::ObjectType::TIMER,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
vcpu_handle {
ty: fidl::Vcpu,
offset_v1: 92,
offset_v2: 92,
handle_metadata: {
handle_subtype: fidl::ObjectType::VCPU,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
vmar_handle {
ty: fidl::Vmar,
offset_v1: 96,
offset_v2: 96,
handle_metadata: {
handle_subtype: fidl::ObjectType::VMAR,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
vmo_handle {
ty: fidl::Vmo,
offset_v1: 100,
offset_v2: 100,
handle_metadata: {
handle_subtype: fidl::ObjectType::VMO,
handle_rights: fidl::Rights::from_bits_const(2147483648).unwrap(),
},
},
rights_handle {
ty: fidl::Vmo,
offset_v1: 104,
offset_v2: 104,
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: 108,
offset_v2: 108,
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: 112,
offset_v2: 112,
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: 116,
offset_v2: 116,
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: 120,
offset_v2: 120,
handle_metadata: {
handle_subtype: fidl::ObjectType::CHANNEL,
handle_rights: fidl::Rights::CHANNEL_DEFAULT,
},
},
request_some_protocol {
ty: fidl::endpoints::ServerEnd<SomeProtocolMarker>,
offset_v1: 124,
offset_v2: 124,
handle_metadata: {
handle_subtype: fidl::ObjectType::CHANNEL,
handle_rights: fidl::Rights::CHANNEL_DEFAULT,
},
},
],
padding_v1: [],
padding_v2: [],
size_v1: 128,
size_v2: 128,
align_v1: 4,
align_v2: 4,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct SomeProtocolMarker;
impl fidl::endpoints::ProtocolMarker 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 protocol_name = <SomeProtocolMarker 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()
}
/// Waits until an event arrives and returns it. It is safe for other
/// threads to make concurrent requests while waiting for an event.
pub fn wait_for_event(&self, deadline: zx::Time) -> Result<SomeProtocolEvent, fidl::Error> {
SomeProtocolEvent::decode(self.client.wait_for_event(deadline)?)
}
}
#[derive(Debug, Clone)]
pub struct SomeProtocolProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for SomeProtocolProxy {
type Protocol = 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 protocol_name = <SomeProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_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 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),
};
std::task::Poll::Ready(Some(SomeProtocolEvent::decode(buf)))
}
}
#[derive(Debug)]
pub enum SomeProtocolEvent {}
impl SomeProtocolEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<SomeProtocolEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
match tx_header.ordinal() {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal(),
protocol_name: <SomeProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
/// 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 Protocol = SomeProtocolMarker;
type ControlHandle = SomeProtocolControlHandle;
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 {
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(),
protocol_name:
<SomeProtocolMarker as fidl::endpoints::ProtocolMarker>::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 {}
}
}
#[derive(Debug, Clone)]
pub struct SomeProtocolControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for SomeProtocolControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
}
impl SomeProtocolControlHandle {}