#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use {
bitflags::bitflags,
fidl::{
client::QueryResponseFut,
endpoints::{ControlHandle as _, Responder as _},
},
fuchsia_zircon_status as zx_status,
futures::future::{self, MaybeDone, TryFutureExt},
};
#[cfg(target_os = "fuchsia")]
use fuchsia_zircon as zx;
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ConscriptIssueRequest {
pub iface: fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
pub request: Option<String>,
}
impl fidl::Standalone for ConscriptIssueRequest {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ConscriptIssueResponse {
pub response: Option<String>,
}
impl fidl::Persistable for ConscriptIssueResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ConscriptServeRequest {
pub iface: fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
}
impl fidl::Standalone for ConscriptServeRequest {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ConscriptMarker;
impl fidl::endpoints::ProtocolMarker for ConscriptMarker {
type Proxy = ConscriptProxy;
type RequestStream = ConscriptRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = ConscriptSynchronousProxy;
const DEBUG_NAME: &'static str = "test.triangle.Conscript";
}
impl fidl::endpoints::DiscoverableProtocolMarker for ConscriptMarker {}
pub trait ConscriptProxyInterface: Send + Sync {
fn r#serve(
&self,
iface: fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
) -> Result<(), fidl::Error>;
type IssueResponseFut: std::future::Future<Output = Result<Option<String>, fidl::Error>> + Send;
fn r#issue(
&self,
iface: fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
request: Option<&str>,
) -> Self::IssueResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct ConscriptSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for ConscriptSynchronousProxy {
type Proxy = ConscriptProxy;
type Protocol = ConscriptMarker;
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 ConscriptSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <ConscriptMarker 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::Time) -> Result<ConscriptEvent, fidl::Error> {
ConscriptEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#serve(
&self,
mut iface: fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
) -> Result<(), fidl::Error> {
self.client.send::<ConscriptServeRequest>(
(iface,),
0xec2f1bfefaaf878,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#issue(
&self,
mut iface: fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
mut request: Option<&str>,
___deadline: zx::Time,
) -> Result<Option<String>, fidl::Error> {
let _response = self.client.send_query::<ConscriptIssueRequest, ConscriptIssueResponse>(
(iface, request),
0x4bcc695ef98ec8a9,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.response)
}
}
#[derive(Debug, Clone)]
pub struct ConscriptProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for ConscriptProxy {
type Protocol = ConscriptMarker;
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 ConscriptProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <ConscriptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> ConscriptEventStream {
ConscriptEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#serve(
&self,
mut iface: fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
) -> Result<(), fidl::Error> {
ConscriptProxyInterface::r#serve(self, iface)
}
pub fn r#issue(
&self,
mut iface: fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
mut request: Option<&str>,
) -> fidl::client::QueryResponseFut<Option<String>> {
ConscriptProxyInterface::r#issue(self, iface, request)
}
}
impl ConscriptProxyInterface for ConscriptProxy {
fn r#serve(
&self,
mut iface: fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
) -> Result<(), fidl::Error> {
self.client.send::<ConscriptServeRequest>(
(iface,),
0xec2f1bfefaaf878,
fidl::encoding::DynamicFlags::empty(),
)
}
type IssueResponseFut = fidl::client::QueryResponseFut<Option<String>>;
fn r#issue(
&self,
mut iface: fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
mut request: Option<&str>,
) -> Self::IssueResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<Option<String>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
ConscriptIssueResponse,
0x4bcc695ef98ec8a9,
>(_buf?)?;
Ok(_response.response)
}
self.client.send_query_and_decode::<ConscriptIssueRequest, Option<String>>(
(iface, request),
0x4bcc695ef98ec8a9,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct ConscriptEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for ConscriptEventStream {}
impl futures::stream::FusedStream for ConscriptEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for ConscriptEventStream {
type Item = Result<ConscriptEvent, 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(ConscriptEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum ConscriptEvent {}
impl ConscriptEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<ConscriptEvent, 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: <ConscriptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct ConscriptRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for ConscriptRequestStream {}
impl futures::stream::FusedStream for ConscriptRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for ConscriptRequestStream {
type Protocol = ConscriptMarker;
type ControlHandle = ConscriptControlHandle;
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 {
ConscriptControlHandle { 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 ConscriptRequestStream {
type Item = Result<ConscriptRequest, 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 ConscriptRequestStream 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))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0xec2f1bfefaaf878 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(ConscriptServeRequest);
fidl::encoding::Decoder::decode_into::<ConscriptServeRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = ConscriptControlHandle { inner: this.inner.clone() };
Ok(ConscriptRequest::Serve { iface: req.iface, control_handle })
}
0x4bcc695ef98ec8a9 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(ConscriptIssueRequest);
fidl::encoding::Decoder::decode_into::<ConscriptIssueRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = ConscriptControlHandle { inner: this.inner.clone() };
Ok(ConscriptRequest::Issue {
iface: req.iface,
request: req.request,
responder: ConscriptIssueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <ConscriptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum ConscriptRequest {
Serve {
iface: fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
control_handle: ConscriptControlHandle,
},
Issue {
iface: fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
request: Option<String>,
responder: ConscriptIssueResponder,
},
}
impl ConscriptRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_serve(
self,
) -> Option<(fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>, ConscriptControlHandle)>
{
if let ConscriptRequest::Serve { iface, control_handle } = self {
Some((iface, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_issue(
self,
) -> Option<(
fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
Option<String>,
ConscriptIssueResponder,
)> {
if let ConscriptRequest::Issue { iface, request, responder } = self {
Some((iface, request, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
ConscriptRequest::Serve { .. } => "serve",
ConscriptRequest::Issue { .. } => "issue",
}
}
}
#[derive(Debug, Clone)]
pub struct ConscriptControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for ConscriptControlHandle {
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()
}
}
impl ConscriptControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct ConscriptIssueResponder {
control_handle: std::mem::ManuallyDrop<ConscriptControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for ConscriptIssueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for ConscriptIssueResponder {
type ControlHandle = ConscriptControlHandle;
fn control_handle(&self) -> &ConscriptControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl ConscriptIssueResponder {
pub fn send(self, mut response: Option<&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: Option<&str>) -> Result<(), fidl::Error> {
let _result = self.send_raw(response);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut response: Option<&str>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<ConscriptIssueResponse>(
(response,),
self.tx_id,
0x4bcc695ef98ec8a9,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for ConscriptIssueRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
24
}
}
impl fidl::encoding::ResourceTypeMarker for ConscriptIssueRequest {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<ConscriptIssueRequest> for &mut ConscriptIssueRequest {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ConscriptIssueRequest>(offset);
fidl::encoding::Encode::<ConscriptIssueRequest>::encode(
(
<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iface),
<fidl::encoding::Optional<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(&self.request),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>>,
>,
T1: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::UnboundedString>>,
> fidl::encoding::Encode<ConscriptIssueRequest> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ConscriptIssueRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for ConscriptIssueRequest {
#[inline(always)]
fn new_empty() -> Self {
Self {
iface: fidl::new_empty!(
fidl::encoding::Endpoint<
fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
>
),
request: fidl::new_empty!(
fidl::encoding::Optional<fidl::encoding::UnboundedString>
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>>,
&mut self.iface,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
fidl::encoding::Optional<fidl::encoding::UnboundedString>,
&mut self.request,
decoder,
offset + 8,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for ConscriptIssueResponse {
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
}
}
impl fidl::encoding::ValueTypeMarker for ConscriptIssueResponse {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<ConscriptIssueResponse> for &ConscriptIssueResponse {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ConscriptIssueResponse>(offset);
fidl::encoding::Encode::<ConscriptIssueResponse>::encode(
(
<fidl::encoding::Optional<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(&self.response),
),
encoder, offset, _depth
)
}
}
unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::UnboundedString>>>
fidl::encoding::Encode<ConscriptIssueResponse> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ConscriptIssueResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for ConscriptIssueResponse {
#[inline(always)]
fn new_empty() -> Self {
Self {
response: fidl::new_empty!(
fidl::encoding::Optional<fidl::encoding::UnboundedString>
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::Optional<fidl::encoding::UnboundedString>,
&mut self.response,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for ConscriptServeRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
}
impl fidl::encoding::ResourceTypeMarker for ConscriptServeRequest {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<ConscriptServeRequest> for &mut ConscriptServeRequest {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ConscriptServeRequest>(offset);
fidl::encoding::Encode::<ConscriptServeRequest>::encode(
(
<fidl::encoding::Endpoint<
fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
&mut self.iface
),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>>,
>,
> fidl::encoding::Encode<ConscriptServeRequest> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ConscriptServeRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for ConscriptServeRequest {
#[inline(always)]
fn new_empty() -> Self {
Self {
iface: fidl::new_empty!(
fidl::encoding::Endpoint<
fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
>
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>>,
&mut self.iface,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
}