blob: 8618a0b91228562481ead0ab5bbe92aace94b31d [file] [log] [blame] [edit]
// WARNING: This file is machine generated by fidlgen.
// fidl_experiment = output_index_json
#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use bitflags::bitflags;
use fidl::client::QueryResponseFut;
use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
use fidl::endpoints::{ControlHandle as _, Responder as _};
pub use fidl_test_doccomments__common::*;
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct InterfaceMarker;
impl fidl::endpoints::ProtocolMarker for InterfaceMarker {
type Proxy = InterfaceProxy;
type RequestStream = InterfaceRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = InterfaceSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) Interface";
}
pub trait InterfaceProxyInterface: Send + Sync {
fn r#method(&self) -> Result<(), fidl::Error>;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct InterfaceSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for InterfaceSynchronousProxy {
type Proxy = InterfaceProxy;
type Protocol = InterfaceMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl InterfaceSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <InterfaceMarker 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::MonotonicInstant,
) -> Result<InterfaceEvent, fidl::Error> {
InterfaceEvent::decode(self.client.wait_for_event(deadline)?)
}
/// method comment #1
///
/// method comment #3
pub fn r#method(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x45a0257b7cd8f999,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[cfg(target_os = "fuchsia")]
impl From<InterfaceSynchronousProxy> for zx::Handle {
fn from(value: InterfaceSynchronousProxy) -> Self {
value.into_channel().into()
}
}
#[cfg(target_os = "fuchsia")]
impl From<fidl::Channel> for InterfaceSynchronousProxy {
fn from(value: fidl::Channel) -> Self {
Self::new(value)
}
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::FromClient for InterfaceSynchronousProxy {
type Protocol = InterfaceMarker;
fn from_client(value: fidl::endpoints::ClientEnd<InterfaceMarker>) -> Self {
Self::new(value.into_channel())
}
}
#[derive(Debug, Clone)]
pub struct InterfaceProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for InterfaceProxy {
type Protocol = InterfaceMarker;
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 InterfaceProxy {
/// Create a new Proxy for test.doccomments/Interface.
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <InterfaceMarker 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 protocol.
///
/// # Panics
///
/// Panics if the event stream was already taken.
pub fn take_event_stream(&self) -> InterfaceEventStream {
InterfaceEventStream { event_receiver: self.client.take_event_receiver() }
}
/// method comment #1
///
/// method comment #3
pub fn r#method(&self) -> Result<(), fidl::Error> {
InterfaceProxyInterface::r#method(self)
}
}
impl InterfaceProxyInterface for InterfaceProxy {
fn r#method(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x45a0257b7cd8f999,
fidl::encoding::DynamicFlags::empty(),
)
}
}
pub struct InterfaceEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
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>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(InterfaceEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[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 }
}
/// Decodes a message buffer as a [`InterfaceEvent`].
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<InterfaceEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
0x663f6d5971bef0 => {
let mut out = fidl::new_empty!(
fidl::encoding::EmptyPayload,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
Ok((InterfaceEvent::OnEvent {}))
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <InterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
/// A Stream of incoming requests for test.doccomments/Interface.
pub struct InterfaceRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
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 Protocol = InterfaceMarker;
type ControlHandle = InterfaceControlHandle;
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 {
InterfaceControlHandle { inner: self.inner.clone() }
}
fn into_inner(
self,
) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
{
(self.inner, self.is_terminated)
}
fn from_inner(
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
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.check_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_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
|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.into(),
))));
}
}
// A message has been received from the channel
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x45a0257b7cd8f999 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
fidl::encoding::EmptyPayload,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&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,
protocol_name:
<InterfaceMarker as fidl::endpoints::ProtocolMarker>::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",
}
}
}
#[derive(Debug, Clone)]
pub struct InterfaceControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for InterfaceControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().signal_peer(clear_mask, set_mask)
}
}
impl InterfaceControlHandle {
pub fn send_on_event(&self) -> Result<(), fidl::Error> {
self.inner.send::<fidl::encoding::EmptyPayload>(
(),
0,
0x663f6d5971bef0,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ServiceMarker;
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceMarker for ServiceMarker {
type Proxy = ServiceProxy;
type Request = ServiceRequest;
const SERVICE_NAME: &'static str = "test.doccomments.Service";
}
/// A request for one of the member protocols of Service.
///
/// service comment #1
///
/// service comment #3
#[cfg(target_os = "fuchsia")]
pub enum ServiceRequest {
/// member comment #1
///
/// member comment #3
Interface(InterfaceRequestStream),
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceRequest for ServiceRequest {
type Service = ServiceMarker;
fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> 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(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceProxy 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 connect_to_interface(&self) -> Result<InterfaceProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_proxy::<InterfaceMarker>();
self.connect_channel_to_interface(server_end)?;
Ok(proxy)
}
/// Like `connect_to_interface`, but returns a sync proxy.
/// See [`Self::connect_to_interface`] for more details.
pub fn connect_to_interface_sync(&self) -> Result<InterfaceSynchronousProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<InterfaceMarker>();
self.connect_channel_to_interface(server_end)?;
Ok(proxy)
}
/// Like `connect_to_interface`, but accepts a server end.
/// See [`Self::connect_to_interface`] for more details.
pub fn connect_channel_to_interface(
&self,
server_end: fidl::endpoints::ServerEnd<InterfaceMarker>,
) -> Result<(), fidl::Error> {
self.0.open_member("interface", server_end.into_channel())
}
pub fn instance_name(&self) -> &str {
self.0.instance_name()
}
}
mod internal {
use super::*;
}