blob: f7d7a0895fc1632c922c723cd8ba60b7c29e5208 [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
)]
#[allow(unused_imports)]
use fidl::{fidl_bits, fidl_empty_struct, fidl_enum, fidl_struct, fidl_table, fidl_xunion};
#[cfg(target_os = "fuchsia")]
#[allow(unused_imports)]
use fuchsia_zircon as zx;
#[allow(unused_imports)]
use fuchsia_zircon_status as zx_status;
#[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::Handle,
pub aliased_rights_handle_field: fidl::Handle,
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,
},
bti_handle {
ty: fidl::Bti,
offset_v1: 4,
},
channel_handle {
ty: fidl::Channel,
offset_v1: 8,
},
clock_handle {
ty: fidl::Clock,
offset_v1: 12,
},
debuglog_handle {
ty: fidl::DebugLog,
offset_v1: 16,
},
event_handle {
ty: fidl::Event,
offset_v1: 20,
},
eventpair_handle {
ty: fidl::EventPair,
offset_v1: 24,
},
exception_handle {
ty: fidl::Exception,
offset_v1: 28,
},
fifo_handle {
ty: fidl::Fifo,
offset_v1: 32,
},
guest_handle {
ty: fidl::Guest,
offset_v1: 36,
},
interrupt_handle {
ty: fidl::Interrupt,
offset_v1: 40,
},
iommu_handle {
ty: fidl::Iommu,
offset_v1: 44,
},
job_handle {
ty: fidl::Job,
offset_v1: 48,
},
pager_handle {
ty: fidl::Pager,
offset_v1: 52,
},
pcidevice_handle {
ty: fidl::PciDevice,
offset_v1: 56,
},
pmt_handle {
ty: fidl::Pmt,
offset_v1: 60,
},
port_handle {
ty: fidl::Port,
offset_v1: 64,
},
process_handle {
ty: fidl::Process,
offset_v1: 68,
},
profile_handle {
ty: fidl::Profile,
offset_v1: 72,
},
resource_handle {
ty: fidl::Resource,
offset_v1: 76,
},
socket_handle {
ty: fidl::Socket,
offset_v1: 80,
},
suspendtoken_handle {
ty: fidl::SuspendToken,
offset_v1: 84,
},
thread_handle {
ty: fidl::Thread,
offset_v1: 88,
},
timer_handle {
ty: fidl::Timer,
offset_v1: 92,
},
vcpu_handle {
ty: fidl::Vcpu,
offset_v1: 96,
},
vmar_handle {
ty: fidl::Vmar,
offset_v1: 100,
},
vmo_handle {
ty: fidl::Vmo,
offset_v1: 104,
},
rights_handle {
ty: fidl::Vmo,
offset_v1: 108,
},
aliased_plain_handle_field {
ty: fidl::Handle,
offset_v1: 112,
},
aliased_subtype_handle_field {
ty: fidl::Handle,
offset_v1: 116,
},
aliased_rights_handle_field {
ty: fidl::Handle,
offset_v1: 120,
},
some_protocol {
ty: fidl::endpoints::ClientEnd<SomeProtocolMarker>,
offset_v1: 124,
},
request_some_protocol {
ty: fidl::endpoints::ServerEnd<SomeProtocolMarker>,
offset_v1: 128,
},
],
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 {
Self { client: fidl::client::sync::Client::new(channel) }
}
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)
}
}
impl ::std::ops::Deref for SomeProtocolProxy {
type Target = fidl::client::Client;
fn deref(&self) -> &Self::Target {
&self.client
}
}
impl SomeProtocolProxy {
/// Create a new Proxy for SomeProtocol
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
Self { client: fidl::client::Client::new(channel) }
}
/// Attempt to convert the Proxy back into a channel.
///
/// This will only succeed if there are no active clones of this Proxy
/// and no currently-alive EventStream or response futures that came from
/// this Proxy.
pub fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
/// Get a Stream of events from the remote end of the SomeProtocol protocol
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)?;
#[allow(unreachable_patterns)] // GenOrdinal and Ordinal can overlap
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_coding_bufs(|bytes, handles| {
match this.inner.channel().read(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(),
))));
}
#[allow(unreachable_patterns)] // GenOrdinal and Ordinal can overlap
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::Handle],
) -> Result<SomeProtocolRequestMessage, fidl::Error> {
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
#[allow(unreachable_patterns)] // GenOrdinal and Ordinal can overlap
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 ::std::ops::Deref for SomeProtocolControlHandle {
type Target = ::std::sync::Arc<fidl::ServeInner>;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl SomeProtocolControlHandle {
pub fn shutdown(&self) {
self.inner.shutdown()
}
pub fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
}
/* beginning of response types */