#![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 _};
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
pub const MAX_STRING_LENGTH: u64 = 32;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct EchoEchoStringRequest {
pub value: String,
}
impl fidl::Persistable for EchoEchoStringRequest {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct EchoEchoStringResponse {
pub response: String,
}
impl fidl::Persistable for EchoEchoStringResponse {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct EchoMarker;
impl fidl::endpoints::ProtocolMarker for EchoMarker {
type Proxy = EchoProxy;
type RequestStream = EchoRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = EchoSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.examples.Echo";
}
impl fidl::endpoints::DiscoverableProtocolMarker for EchoMarker {}
pub trait EchoProxyInterface: Send + Sync {
type EchoStringResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
fn r#echo_string(&self, value: &str) -> Self::EchoStringResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct EchoSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for EchoSynchronousProxy {
type Proxy = EchoProxy;
type Protocol = EchoMarker;
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 EchoSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <EchoMarker 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()
}
pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<EchoEvent, fidl::Error> {
EchoEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#echo_string(
&self,
mut value: &str,
___deadline: zx::MonotonicInstant,
) -> Result<String, fidl::Error> {
let _response = self.client.send_query::<EchoEchoStringRequest, EchoEchoStringResponse>(
(value,),
0x75b8274e52d9a616,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.response)
}
}
#[derive(Debug, Clone)]
pub struct EchoProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for EchoProxy {
type Protocol = EchoMarker;
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 EchoProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <EchoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> EchoEventStream {
EchoEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#echo_string(
&self,
mut value: &str,
) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
EchoProxyInterface::r#echo_string(self, value)
}
}
impl EchoProxyInterface for EchoProxy {
type EchoStringResponseFut =
fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#echo_string(&self, mut value: &str) -> Self::EchoStringResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<String, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
EchoEchoStringResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x75b8274e52d9a616,
>(_buf?)?;
Ok(_response.response)
}
self.client.send_query_and_decode::<EchoEchoStringRequest, String>(
(value,),
0x75b8274e52d9a616,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct EchoEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for EchoEventStream {}
impl futures::stream::FusedStream for EchoEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for EchoEventStream {
type Item = Result<EchoEvent, 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(EchoEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum EchoEvent {}
impl EchoEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<EchoEvent, 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 {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <EchoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct EchoRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for EchoRequestStream {}
impl futures::stream::FusedStream for EchoRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for EchoRequestStream {
type Protocol = EchoMarker;
type ControlHandle = EchoControlHandle;
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 {
EchoControlHandle { 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 EchoRequestStream {
type Item = Result<EchoRequest, 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 EchoRequestStream 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(),
))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x75b8274e52d9a616 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
EchoEchoStringRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EchoEchoStringRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = EchoControlHandle { inner: this.inner.clone() };
Ok(EchoRequest::EchoString {
value: req.value,
responder: EchoEchoStringResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <EchoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum EchoRequest {
EchoString { value: String, responder: EchoEchoStringResponder },
}
impl EchoRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_echo_string(self) -> Option<(String, EchoEchoStringResponder)> {
if let EchoRequest::EchoString { value, responder } = self {
Some((value, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
EchoRequest::EchoString { .. } => "echo_string",
}
}
}
#[derive(Debug, Clone)]
pub struct EchoControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for EchoControlHandle {
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 EchoControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct EchoEchoStringResponder {
control_handle: std::mem::ManuallyDrop<EchoControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for EchoEchoStringResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for EchoEchoStringResponder {
type ControlHandle = EchoControlHandle;
fn control_handle(&self) -> &EchoControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl EchoEchoStringResponder {
pub fn send(self, mut response: &str) -> Result<(), fidl::Error> {
let _result = self.send_raw(response);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut response: &str) -> Result<(), fidl::Error> {
let _result = self.send_raw(response);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut response: &str) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<EchoEchoStringResponse>(
(response,),
self.tx_id,
0x75b8274e52d9a616,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct EchoServiceMarker;
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceMarker for EchoServiceMarker {
type Proxy = EchoServiceProxy;
type Request = EchoServiceRequest;
const SERVICE_NAME: &'static str = "fuchsia.examples.EchoService";
}
#[cfg(target_os = "fuchsia")]
pub enum EchoServiceRequest {
RegularEcho(EchoRequestStream),
ReversedEcho(EchoRequestStream),
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceRequest for EchoServiceRequest {
type Service = EchoServiceMarker;
fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
match name {
"regular_echo" => Self::RegularEcho(
<EchoRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
),
"reversed_echo" => Self::ReversedEcho(
<EchoRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
),
_ => panic!("no such member protocol name for service EchoService"),
}
}
fn member_names() -> &'static [&'static str] {
&["regular_echo", "reversed_echo"]
}
}
#[cfg(target_os = "fuchsia")]
pub struct EchoServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceProxy for EchoServiceProxy {
type Service = EchoServiceMarker;
fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
Self(opener)
}
}
#[cfg(target_os = "fuchsia")]
impl EchoServiceProxy {
pub fn connect_to_regular_echo(&self) -> Result<EchoProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_proxy::<EchoMarker>();
self.connect_channel_to_regular_echo(server_end)?;
Ok(proxy)
}
pub fn connect_to_regular_echo_sync(&self) -> Result<EchoSynchronousProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<EchoMarker>();
self.connect_channel_to_regular_echo(server_end)?;
Ok(proxy)
}
pub fn connect_channel_to_regular_echo(
&self,
server_end: fidl::endpoints::ServerEnd<EchoMarker>,
) -> Result<(), fidl::Error> {
self.0.open_member("regular_echo", server_end.into_channel())
}
pub fn connect_to_reversed_echo(&self) -> Result<EchoProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_proxy::<EchoMarker>();
self.connect_channel_to_reversed_echo(server_end)?;
Ok(proxy)
}
pub fn connect_to_reversed_echo_sync(&self) -> Result<EchoSynchronousProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<EchoMarker>();
self.connect_channel_to_reversed_echo(server_end)?;
Ok(proxy)
}
pub fn connect_channel_to_reversed_echo(
&self,
server_end: fidl::endpoints::ServerEnd<EchoMarker>,
) -> Result<(), fidl::Error> {
self.0.open_member("reversed_echo", server_end.into_channel())
}
}
mod internal {
use super::*;
impl fidl::encoding::ValueTypeMarker for EchoEchoStringRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for EchoEchoStringRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EchoEchoStringRequest, D>
for &EchoEchoStringRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<EchoEchoStringRequest>(offset);
fidl::encoding::Encode::<EchoEchoStringRequest, D>::encode(
(<fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(
&self.value,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::BoundedString<32>, D>,
> fidl::encoding::Encode<EchoEchoStringRequest, D> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<EchoEchoStringRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EchoEchoStringRequest {
#[inline(always)]
fn new_empty() -> Self {
Self { value: fidl::new_empty!(fidl::encoding::BoundedString<32>, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::BoundedString<32>,
D,
&mut self.value,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for EchoEchoStringResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for EchoEchoStringResponse {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<EchoEchoStringResponse, D> for &EchoEchoStringResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<EchoEchoStringResponse>(offset);
fidl::encoding::Encode::<EchoEchoStringResponse, D>::encode(
(<fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(
&self.response,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::BoundedString<32>, D>,
> fidl::encoding::Encode<EchoEchoStringResponse, D> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<EchoEchoStringResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for EchoEchoStringResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { response: fidl::new_empty!(fidl::encoding::BoundedString<32>, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::BoundedString<32>,
D,
&mut self.response,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
}