blob: ca30678d5f8756f0222f6323800bf3dba1534e6c [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 Testing {
pub u1: u64,
pub u2: Vec<u64>,
pub u3: [u64; 1],
pub u4: Vec<Vec<u64>>,
pub u5: Vec<[u64; 1]>,
pub u6: [Vec<u64>; 4],
pub u7: [[u64; 1]; 4],
pub v1: Option<Vec<u64>>,
pub v2: Vec<Option<Vec<u64>>>,
pub v3: [Option<Vec<u64>>; 4],
pub a1: [u64; 1],
pub a2: Vec<[u64; 1]>,
pub a3: [[u64; 1]; 4],
pub r1: Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>,
pub r2: Vec<Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>>,
pub r3: [Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>; 4],
pub b1: Vec<u8>,
pub b2: Vec<Vec<u8>>,
pub b3: [Vec<u8>; 4],
pub s1: String,
pub s2: Vec<String>,
pub s3: [String; 4],
pub vv1: Vec<u64>,
pub vv2: Vec<Vec<u64>>,
pub vv3: [Vec<u64>; 3],
pub aa1: [u64; 2],
pub aa2: Vec<[u64; 2]>,
pub aa3: [[u64; 2]; 3],
}
fidl_struct! {
name: Testing,
members: [
u1 {
ty: u64,
offset_v1: 0,
offset_v2: 0,
},
u2 {
ty: Vec<u64>,
offset_v1: 8,
offset_v2: 8,
},
u3 {
ty: [u64; 1],
offset_v1: 24,
offset_v2: 24,
},
u4 {
ty: Vec<Vec<u64>>,
offset_v1: 32,
offset_v2: 32,
},
u5 {
ty: Vec<[u64; 1]>,
offset_v1: 48,
offset_v2: 48,
},
u6 {
ty: [Vec<u64>; 4],
offset_v1: 64,
offset_v2: 64,
},
u7 {
ty: [[u64; 1]; 4],
offset_v1: 128,
offset_v2: 128,
},
v1 {
ty: Option<Vec<u64>>,
offset_v1: 160,
offset_v2: 160,
},
v2 {
ty: Vec<Option<Vec<u64>>>,
offset_v1: 176,
offset_v2: 176,
},
v3 {
ty: [Option<Vec<u64>>; 4],
offset_v1: 192,
offset_v2: 192,
},
a1 {
ty: [u64; 1],
offset_v1: 256,
offset_v2: 256,
},
a2 {
ty: Vec<[u64; 1]>,
offset_v1: 264,
offset_v2: 264,
},
a3 {
ty: [[u64; 1]; 4],
offset_v1: 280,
offset_v2: 280,
},
r1 {
ty: Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>,
offset_v1: 312,
offset_v2: 312,
handle_metadata: {
handle_subtype: fidl::ObjectType::CHANNEL,
handle_rights: fidl::Rights::CHANNEL_DEFAULT,
},
},
r2 {
ty: Vec<Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>>,
offset_v1: 320,
offset_v2: 320,
handle_metadata: {
handle_subtype: fidl::ObjectType::CHANNEL,
handle_rights: fidl::Rights::CHANNEL_DEFAULT,
},
},
r3 {
ty: [Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>; 4],
offset_v1: 336,
offset_v2: 336,
handle_metadata: {
handle_subtype: fidl::ObjectType::CHANNEL,
handle_rights: fidl::Rights::CHANNEL_DEFAULT,
},
},
b1 {
ty: Vec<u8>,
offset_v1: 352,
offset_v2: 352,
},
b2 {
ty: Vec<Vec<u8>>,
offset_v1: 368,
offset_v2: 368,
},
b3 {
ty: [Vec<u8>; 4],
offset_v1: 384,
offset_v2: 384,
},
s1 {
ty: String,
offset_v1: 448,
offset_v2: 448,
},
s2 {
ty: Vec<String>,
offset_v1: 464,
offset_v2: 464,
},
s3 {
ty: [String; 4],
offset_v1: 480,
offset_v2: 480,
},
vv1 {
ty: Vec<u64>,
offset_v1: 544,
offset_v2: 544,
},
vv2 {
ty: Vec<Vec<u64>>,
offset_v1: 560,
offset_v2: 560,
},
vv3 {
ty: [Vec<u64>; 3],
offset_v1: 576,
offset_v2: 576,
},
aa1 {
ty: [u64; 2],
offset_v1: 624,
offset_v2: 624,
},
aa2 {
ty: Vec<[u64; 2]>,
offset_v1: 640,
offset_v2: 640,
},
aa3 {
ty: [[u64; 2]; 3],
offset_v1: 656,
offset_v2: 656,
},
],
padding_v1: [
{
ty: u64,
offset: 312,
mask: 0xffffffff00000000u64,
},],
padding_v2: [
{
ty: u64,
offset: 312,
mask: 0xffffffff00000000u64,
},],
size_v1: 704,
size_v2: 704,
align_v1: 8,
align_v2: 8,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct MyProtocolMarker;
impl fidl::endpoints::ProtocolMarker for MyProtocolMarker {
type Proxy = MyProtocolProxy;
type RequestStream = MyProtocolRequestStream;
const DEBUG_NAME: &'static str = "(anonymous) MyProtocol";
}
pub trait MyProtocolProxyInterface: Send + Sync {}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct MyProtocolSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl MyProtocolSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <MyProtocolMarker 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<MyProtocolEvent, fidl::Error> {
MyProtocolEvent::decode(self.client.wait_for_event(deadline)?)
}
}
#[derive(Debug, Clone)]
pub struct MyProtocolProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for MyProtocolProxy {
type Protocol = MyProtocolMarker;
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 MyProtocolProxy {
/// Create a new Proxy for MyProtocol
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <MyProtocolMarker 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 MyProtocol protocol
///
/// # Panics
///
/// Panics if the event stream was already taken.
pub fn take_event_stream(&self) -> MyProtocolEventStream {
MyProtocolEventStream { event_receiver: self.client.take_event_receiver() }
}
}
impl MyProtocolProxyInterface for MyProtocolProxy {}
pub struct MyProtocolEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for MyProtocolEventStream {}
impl futures::stream::FusedStream for MyProtocolEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for MyProtocolEventStream {
type Item = Result<MyProtocolEvent, 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(MyProtocolEvent::decode(buf)))
}
}
#[derive(Debug)]
pub enum MyProtocolEvent {}
impl MyProtocolEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<MyProtocolEvent, 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: <MyProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
/// A Stream of incoming requests for MyProtocol
pub struct MyProtocolRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for MyProtocolRequestStream {}
impl futures::stream::FusedStream for MyProtocolRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for MyProtocolRequestStream {
type Protocol = MyProtocolMarker;
type ControlHandle = MyProtocolControlHandle;
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 {
MyProtocolControlHandle { 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 MyProtocolRequestStream {
type Item = Result<MyProtocolRequest, 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 MyProtocolRequestStream 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:
<MyProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum MyProtocolRequest {}
impl MyProtocolRequest {
/// Name of the method defined in FIDL
pub fn method_name(&self) -> &'static str {
match *self {}
}
}
#[derive(Debug, Clone)]
pub struct MyProtocolControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for MyProtocolControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
}
impl MyProtocolControlHandle {}