blob: 63c0dc7f5b4c1bccffd04247fc2c1effd504b8d8 [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;
fidl_bits! {
MyBits(u32) {
MyFirstBit = 1,
MyOtherBit = 2,
}
}
/// const comment #1
///
/// const comment #3
pub const C: i32 = 4;
fidl_enum! {
MyEnum(u32) {
Foo = 1,
Bar = 2,
}
}
fidl_xunion! {
/// union comment #1
///
/// union comment #3
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
name: Union,
members: [
/// union member comment #1
///
/// union member comment #3
Field {
ty: i32,
ordinal: 1,
},
],
}
/// struct comment #1
///
/// struct comment #3
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct Struct {
/// struct member comment #1
///
/// struct member comment #3
pub field: i32,
}
fidl_struct! {
name: Struct,
members: [
field {
ty: i32,
offset_v1: 0,
},
],
size_v1: 4,
align_v1: 4,
}
/// table comment #1
///
/// table comment #3
#[derive(Debug, PartialEq)]
pub struct Table {
/// table field comment #1
///
/// table field comment #3
pub field: Option<i32>,
}
fidl_table! {
name: Table,
members: {
field {
ty: i32,
ordinal: 1,
},
},
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct InterfaceMarker;
impl fidl::endpoints::ServiceMarker for InterfaceMarker {
type Proxy = InterfaceProxy;
type RequestStream = InterfaceRequestStream;
const DEBUG_NAME: &'static str = "(anonymous) Interface";
}
pub trait InterfaceProxyInterface: Send + Sync {
fn method(&self) -> Result<(), fidl::Error>;
type OnEventResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct InterfaceSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl InterfaceSynchronousProxy {
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()
}
/// method comment #1
///
/// method comment #3
pub fn method(&mut self) -> Result<(), fidl::Error> {
self.client.send(&mut (), 0x60e700e002995ef8)
}
}
#[derive(Debug, Clone)]
pub struct InterfaceProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for InterfaceProxy {
type Service = InterfaceMarker;
fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
Self::new(inner)
}
}
impl ::std::ops::Deref for InterfaceProxy {
type Target = fidl::client::Client;
fn deref(&self) -> &Self::Target {
&self.client
}
}
impl InterfaceProxy {
/// Create a new Proxy for Interface
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 Interface protocol
pub fn take_event_stream(&self) -> InterfaceEventStream {
InterfaceEventStream { event_receiver: self.client.take_event_receiver() }
}
/// method comment #1
///
/// method comment #3
pub fn method(&self) -> Result<(), fidl::Error> {
InterfaceProxyInterface::method(self)
}
}
impl InterfaceProxyInterface for InterfaceProxy {
fn method(&self) -> Result<(), fidl::Error> {
self.client.send(&mut (), 0x60e700e002995ef8)
}
type OnEventResponseFut = fidl::client::QueryResponseFut<()>;
}
pub struct InterfaceEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl ::std::marker::Unpin for InterfaceEventStream {}
impl futures::stream::FusedStream for InterfaceEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for InterfaceEventStream {
type Item = Result<InterfaceEvent, 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() {
0x136d200d00000000 | 0x914c226136244ed => {
let mut out_tuple: () = fidl::encoding::Decodable::new_empty();
fidl::encoding::Decoder::decode_into(
&tx_header,
_body_bytes,
_handles,
&mut out_tuple,
)?;
Ok((InterfaceEvent::OnEvent {}))
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal(),
service_name: <InterfaceMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME,
}),
}))
}
}
#[derive(Debug)]
pub enum InterfaceEvent {
OnEvent {},
}
impl InterfaceEvent {
#[allow(irrefutable_let_patterns)]
pub fn into_on_event(self) -> Option<()> {
if let InterfaceEvent::OnEvent {} = self {
Some(())
} else {
None
}
}
}
/// 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 InterfaceRequestStream / Responder instead")]
pub struct InterfaceServerSender<'a> {
// Some protocols don't define events which would render this channel unused.
#[allow(unused)]
channel: &'a ::fidl::Channel,
}
impl<'a> InterfaceServerSender<'a> {
pub fn new(channel: &'a ::fidl::Channel) -> Self {
Self { channel }
}
pub fn send_on_event(&self) -> Result<(), fidl::Error> {
::fidl::encoding::with_tls_coding_bufs(|bytes, handles| {
InterfaceEncoder::encode_on_event_response(bytes, handles)?;
self.channel.write(&*bytes, &mut *handles).map_err(fidl::Error::ServerResponseWrite)?;
Ok(())
})
}
}
/// A Stream of incoming requests for Interface
pub struct InterfaceRequestStream {
inner: ::std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl ::std::marker::Unpin for InterfaceRequestStream {}
impl futures::stream::FusedStream for InterfaceRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for InterfaceRequestStream {
type Service = InterfaceMarker;
/// Consume a channel to make a InterfaceRequestStream
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 = InterfaceControlHandle;
/// ControlHandle for the remote connection
fn control_handle(&self) -> Self::ControlHandle {
InterfaceControlHandle { 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 InterfaceRequestStream {
type Item = Result<InterfaceRequest, 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 InterfaceRequestStream 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() {
0x3f43684c00000000 | 0x60e700e002995ef8 => {
let mut req: () = fidl::encoding::Decodable::new_empty();
fidl::encoding::Decoder::decode_into(&header, _body_bytes, handles, &mut req)?;
let control_handle = InterfaceControlHandle { inner: this.inner.clone() };
Ok(InterfaceRequest::Method { control_handle })
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal(),
service_name: <InterfaceMarker 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 InterfaceRequest instead")]
pub enum InterfaceRequestMessage {
/// method comment #1
///
/// method comment #3
Method {},
}
impl InterfaceRequestMessage {
pub fn decode(
bytes: &[u8],
_handles: &mut [fidl::Handle],
) -> Result<InterfaceRequestMessage, fidl::Error> {
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
#[allow(unreachable_patterns)] // GenOrdinal and Ordinal can overlap
match header.ordinal() {
0x3f43684c00000000 | 0x60e700e002995ef8 => {
let mut out_tuple: () = fidl::encoding::Decodable::new_empty();
fidl::encoding::Decoder::decode_into(
&header,
_body_bytes,
_handles,
&mut out_tuple,
)?;
Ok(InterfaceRequestMessage::Method {})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal(),
service_name: <InterfaceMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME,
}),
}
}
}
/// interface comment #1
///
/// interface comment #3
#[derive(Debug)]
pub enum InterfaceRequest {
/// method comment #1
///
/// method comment #3
Method { control_handle: InterfaceControlHandle },
}
impl InterfaceRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_method(self) -> Option<(InterfaceControlHandle)> {
if let InterfaceRequest::Method { control_handle } = self {
Some((control_handle))
} else {
None
}
}
/// Name of the method defined in FIDL
pub fn method_name(&self) -> &'static str {
match *self {
InterfaceRequest::Method { .. } => "method",
}
}
}
pub struct InterfaceEncoder;
impl InterfaceEncoder {
pub fn encode_method_request<'a>(
out_bytes: &'a mut Vec<u8>,
out_handles: &'a mut Vec<fidl::Handle>,
) -> Result<(), fidl::Error> {
let header = fidl::encoding::TransactionHeader::new(0, 0x60e700e002995ef8);
let mut body = ();
let mut msg = fidl::encoding::TransactionMessage { header, body: &mut body };
fidl::encoding::Encoder::encode(out_bytes, out_handles, &mut msg)?;
Ok(())
}
pub fn encode_on_event_response<'a>(
out_bytes: &'a mut Vec<u8>,
out_handles: &'a mut Vec<fidl::Handle>,
) -> Result<(), fidl::Error> {
let header = fidl::encoding::TransactionHeader::new(0, 0x914c226136244ed);
let mut body = ();
let mut msg = fidl::encoding::TransactionMessage { header, body: &mut body };
fidl::encoding::Encoder::encode(out_bytes, out_handles, &mut msg)?;
Ok(())
}
}
#[derive(Debug, Clone)]
pub struct InterfaceControlHandle {
inner: ::std::sync::Arc<fidl::ServeInner>,
}
impl ::std::ops::Deref for InterfaceControlHandle {
type Target = ::std::sync::Arc<fidl::ServeInner>;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl InterfaceControlHandle {
pub fn shutdown(&self) {
self.inner.shutdown()
}
pub fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
pub fn send_on_event(&self) -> Result<(), fidl::Error> {
let header = fidl::encoding::TransactionHeader::new(0, 0x914c226136244ed);
let mut response = ();
let mut msg = fidl::encoding::TransactionMessage { header, body: &mut response };
::fidl::encoding::with_tls_encoded(&mut msg, |bytes, handles| {
self.inner
.channel()
.write(&*bytes, &mut *handles)
.map_err(fidl::Error::ServerResponseWrite)
})?;
Ok(())
}
}
/* beginning of response types */
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ServiceMarker;
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::UnifiedServiceMarker for ServiceMarker {
type Proxy = ServiceProxy;
type Request = ServiceRequest;
const SERVICE_NAME: &'static str = "test.name.Service";
}
/// A request for one of the member protocols of Service.
///
/// service comment #1
///
/// service comment #3
#[cfg(target_os = "fuchsia")]
pub enum ServiceRequest {
/// service comment #1
///
/// service comment #3
Interface(InterfaceRequestStream),
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::UnifiedServiceRequest for ServiceRequest {
type Service = ServiceMarker;
fn dispatch(name: &str, channel: ::fuchsia_async::Channel) -> Self {
match name {
"interface" => Self::Interface(
<InterfaceRequestStream as fidl::endpoints::RequestStream>::from_channel(channel),
),
_ => panic!("no such member protocol name for service Service"),
}
}
fn member_names() -> &'static [&'static str] {
&["interface"]
}
}
/// service comment #1
///
/// service comment #3
#[cfg(target_os = "fuchsia")]
pub struct ServiceProxy(Box<dyn fidl::endpoints::MemberOpener>);
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::UnifiedServiceProxy for ServiceProxy {
type Service = ServiceMarker;
fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
Self(opener)
}
}
#[cfg(target_os = "fuchsia")]
impl ServiceProxy {
/// member comment #1
///
/// member comment #3
pub fn interface(&self) -> Result<InterfaceProxy, fidl::Error> {
let (proxy, server) = zx::Channel::create().map_err(fidl::Error::ChannelPairCreate)?;
self.0.open_member("interface", server)?;
let proxy =
::fuchsia_async::Channel::from_channel(proxy).map_err(fidl::Error::AsyncChannel)?;
Ok(InterfaceProxy::new(proxy))
}
}