blob: 7c98e7796de07e13700d71b699d47ee9c6d410ec [file] [log] [blame]
// 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_versions__common::*;
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct Struct {
pub x: u32,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Struct {}
#[derive(Debug, Default, PartialEq)]
pub struct Table {
pub x: Option<u32>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Table {}
#[derive(Debug)]
pub enum Union {
X(u32),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `Union` member.
#[macro_export]
macro_rules! UnionUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for Union {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::X(x), Self::X(y)) => *x == *y,
_ => false,
}
}
}
impl Union {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::X(_) => 1,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn unknown_variant_for_testing() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { .. } => true,
_ => false,
}
}
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Union {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct OtherProtocolMarker;
impl fidl::endpoints::ProtocolMarker for OtherProtocolMarker {
type Proxy = OtherProtocolProxy;
type RequestStream = OtherProtocolRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = OtherProtocolSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) OtherProtocol";
}
pub trait OtherProtocolProxyInterface: Send + Sync {}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct OtherProtocolSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for OtherProtocolSynchronousProxy {
type Proxy = OtherProtocolProxy;
type Protocol = OtherProtocolMarker;
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 OtherProtocolSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <OtherProtocolMarker 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<OtherProtocolEvent, fidl::Error> {
OtherProtocolEvent::decode(self.client.wait_for_event(deadline)?)
}
}
#[cfg(target_os = "fuchsia")]
impl From<OtherProtocolSynchronousProxy> for zx::Handle {
fn from(value: OtherProtocolSynchronousProxy) -> Self {
value.into_channel().into()
}
}
#[cfg(target_os = "fuchsia")]
impl From<fidl::Channel> for OtherProtocolSynchronousProxy {
fn from(value: fidl::Channel) -> Self {
Self::new(value)
}
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::FromClient for OtherProtocolSynchronousProxy {
type Protocol = OtherProtocolMarker;
fn from_client(value: fidl::endpoints::ClientEnd<OtherProtocolMarker>) -> Self {
Self::new(value.into_channel())
}
}
#[derive(Debug, Clone)]
pub struct OtherProtocolProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for OtherProtocolProxy {
type Protocol = OtherProtocolMarker;
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 OtherProtocolProxy {
/// Create a new Proxy for test.versions/OtherProtocol.
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <OtherProtocolMarker 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) -> OtherProtocolEventStream {
OtherProtocolEventStream { event_receiver: self.client.take_event_receiver() }
}
}
impl OtherProtocolProxyInterface for OtherProtocolProxy {}
pub struct OtherProtocolEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for OtherProtocolEventStream {}
impl futures::stream::FusedStream for OtherProtocolEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for OtherProtocolEventStream {
type Item = Result<OtherProtocolEvent, 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(OtherProtocolEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum OtherProtocolEvent {}
impl OtherProtocolEvent {
/// Decodes a message buffer as a [`OtherProtocolEvent`].
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<OtherProtocolEvent, 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: <OtherProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
/// A Stream of incoming requests for test.versions/OtherProtocol.
pub struct OtherProtocolRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for OtherProtocolRequestStream {}
impl futures::stream::FusedStream for OtherProtocolRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for OtherProtocolRequestStream {
type Protocol = OtherProtocolMarker;
type ControlHandle = OtherProtocolControlHandle;
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 {
OtherProtocolControlHandle { 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 OtherProtocolRequestStream {
type Item = Result<OtherProtocolRequest, 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 OtherProtocolRequestStream 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 {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<OtherProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum OtherProtocolRequest {}
impl OtherProtocolRequest {
/// Name of the method defined in FIDL
pub fn method_name(&self) -> &'static str {
match *self {}
}
}
#[derive(Debug, Clone)]
pub struct OtherProtocolControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for OtherProtocolControlHandle {
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 OtherProtocolControlHandle {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ProtocolMarker;
impl fidl::endpoints::ProtocolMarker for ProtocolMarker {
type Proxy = ProtocolProxy;
type RequestStream = ProtocolRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = ProtocolSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) Protocol";
}
pub trait ProtocolProxyInterface: Send + Sync {
fn r#foo(&self) -> Result<(), fidl::Error>;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct ProtocolSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for ProtocolSynchronousProxy {
type Proxy = ProtocolProxy;
type Protocol = ProtocolMarker;
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 ProtocolSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <ProtocolMarker 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<ProtocolEvent, fidl::Error> {
ProtocolEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#foo(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x567a8096af6e6139,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[cfg(target_os = "fuchsia")]
impl From<ProtocolSynchronousProxy> for zx::Handle {
fn from(value: ProtocolSynchronousProxy) -> Self {
value.into_channel().into()
}
}
#[cfg(target_os = "fuchsia")]
impl From<fidl::Channel> for ProtocolSynchronousProxy {
fn from(value: fidl::Channel) -> Self {
Self::new(value)
}
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::FromClient for ProtocolSynchronousProxy {
type Protocol = ProtocolMarker;
fn from_client(value: fidl::endpoints::ClientEnd<ProtocolMarker>) -> Self {
Self::new(value.into_channel())
}
}
#[derive(Debug, Clone)]
pub struct ProtocolProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for ProtocolProxy {
type Protocol = ProtocolMarker;
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 ProtocolProxy {
/// Create a new Proxy for test.versions/Protocol.
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <ProtocolMarker 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) -> ProtocolEventStream {
ProtocolEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#foo(&self) -> Result<(), fidl::Error> {
ProtocolProxyInterface::r#foo(self)
}
}
impl ProtocolProxyInterface for ProtocolProxy {
fn r#foo(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x567a8096af6e6139,
fidl::encoding::DynamicFlags::empty(),
)
}
}
pub struct ProtocolEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for ProtocolEventStream {}
impl futures::stream::FusedStream for ProtocolEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for ProtocolEventStream {
type Item = Result<ProtocolEvent, 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(ProtocolEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum ProtocolEvent {
#[non_exhaustive]
_UnknownEvent {
/// Ordinal of the event that was sent.
ordinal: u64,
},
}
impl ProtocolEvent {
/// Decodes a message buffer as a [`ProtocolEvent`].
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<ProtocolEvent, 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 {
_ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
Ok(ProtocolEvent::_UnknownEvent { ordinal: tx_header.ordinal })
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <ProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
/// A Stream of incoming requests for test.versions/Protocol.
pub struct ProtocolRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for ProtocolRequestStream {}
impl futures::stream::FusedStream for ProtocolRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for ProtocolRequestStream {
type Protocol = ProtocolMarker;
type ControlHandle = ProtocolControlHandle;
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 {
ProtocolControlHandle { 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 ProtocolRequestStream {
type Item = Result<ProtocolRequest, 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 ProtocolRequestStream 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 {
0x567a8096af6e6139 => {
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 = ProtocolControlHandle { inner: this.inner.clone() };
Ok(ProtocolRequest::Foo { control_handle })
}
_ if header.tx_id == 0
&& header
.dynamic_flags()
.contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
{
Ok(ProtocolRequest::_UnknownMethod {
ordinal: header.ordinal,
control_handle: ProtocolControlHandle { inner: this.inner.clone() },
method_type: fidl::MethodType::OneWay,
})
}
_ if header
.dynamic_flags()
.contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
{
this.inner.send_framework_err(
fidl::encoding::FrameworkErr::UnknownMethod,
header.tx_id,
header.ordinal,
header.dynamic_flags(),
(bytes, handles),
)?;
Ok(ProtocolRequest::_UnknownMethod {
ordinal: header.ordinal,
control_handle: ProtocolControlHandle { inner: this.inner.clone() },
method_type: fidl::MethodType::TwoWay,
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<ProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum ProtocolRequest {
Foo {
control_handle: ProtocolControlHandle,
},
/// An interaction was received which does not match any known method.
#[non_exhaustive]
_UnknownMethod {
/// Ordinal of the method that was called.
ordinal: u64,
control_handle: ProtocolControlHandle,
method_type: fidl::MethodType,
},
}
impl ProtocolRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_foo(self) -> Option<(ProtocolControlHandle)> {
if let ProtocolRequest::Foo { control_handle } = self {
Some((control_handle))
} else {
None
}
}
/// Name of the method defined in FIDL
pub fn method_name(&self) -> &'static str {
match *self {
ProtocolRequest::Foo { .. } => "foo",
ProtocolRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
"unknown one-way method"
}
ProtocolRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
"unknown two-way method"
}
}
}
}
#[derive(Debug, Clone)]
pub struct ProtocolControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for ProtocolControlHandle {
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 ProtocolControlHandle {}
#[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.versions.Service";
}
/// A request for one of the member protocols of Service.
///
#[cfg(target_os = "fuchsia")]
pub enum ServiceRequest {
P(ProtocolRequestStream),
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceRequest for ServiceRequest {
type Service = ServiceMarker;
fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
match name {
"p" => Self::P(
<ProtocolRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
),
_ => panic!("no such member protocol name for service Service"),
}
}
fn member_names() -> &'static [&'static str] {
&["p"]
}
}
#[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 {
pub fn connect_to_p(&self) -> Result<ProtocolProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_proxy::<ProtocolMarker>();
self.connect_channel_to_p(server_end)?;
Ok(proxy)
}
/// Like `connect_to_p`, but returns a sync proxy.
/// See [`Self::connect_to_p`] for more details.
pub fn connect_to_p_sync(&self) -> Result<ProtocolSynchronousProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ProtocolMarker>();
self.connect_channel_to_p(server_end)?;
Ok(proxy)
}
/// Like `connect_to_p`, but accepts a server end.
/// See [`Self::connect_to_p`] for more details.
pub fn connect_channel_to_p(
&self,
server_end: fidl::endpoints::ServerEnd<ProtocolMarker>,
) -> Result<(), fidl::Error> {
self.0.open_member("p", server_end.into_channel())
}
pub fn instance_name(&self) -> &str {
self.0.instance_name()
}
}
mod internal {
use super::*;
impl fidl::encoding::ResourceTypeMarker for Struct {
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::TypeMarker for Struct {
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
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
unsafe impl fidl::encoding::Encode<Struct, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut Struct
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Struct>(offset);
unsafe {
// Copy the object into the buffer.
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut Struct).write_unaligned((self as *const Struct).read());
// Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
// done second because the memcpy will write garbage to these bytes.
}
Ok(())
}
}
unsafe impl<T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>>
fidl::encoding::Encode<Struct, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Struct>(offset);
// Zero out padding regions. There's no need to apply masks
// because the unmasked parts will be overwritten by fields.
// Write the fields.
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Struct {
#[inline(always)]
fn new_empty() -> Self {
Self { x: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
// Verify that padding bytes are zero.
// Copy from the buffer into the object.
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
impl Table {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.x {
return 1;
}
0
}
}
impl fidl::encoding::ResourceTypeMarker for Table {
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::TypeMarker for Table {
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 fidl::encoding::Encode<Table, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut Table
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Table>(offset);
// Vector header
let max_ordinal: u64 = self.max_ordinal_present();
encoder.write_num(max_ordinal, offset);
encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
// Calling encoder.out_of_line_offset(0) is not allowed.
if max_ordinal == 0 {
return Ok(());
}
depth.increment()?;
let envelope_size = 8;
let bytes_len = max_ordinal as usize * envelope_size;
#[allow(unused_variables)]
let offset = encoder.out_of_line_offset(bytes_len);
let mut _prev_end_offset: usize = 0;
if 1 > max_ordinal {
return Ok(());
}
// Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
// are envelope_size bytes.
let cur_offset: usize = (1 - 1) * envelope_size;
// Zero reserved fields.
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
// Safety:
// - bytes_len is calculated to fit envelope_size*max(member.ordinal).
// - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
// envelope_size bytes, there is always sufficient room.
fidl::encoding::encode_in_envelope_optional::<
u32,
fidl::encoding::DefaultFuchsiaResourceDialect,
>(
self.x.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Table {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
None => return Err(fidl::Error::NotNullable),
Some(len) => len,
};
// Calling decoder.out_of_line_offset(0) is not allowed.
if len == 0 {
return Ok(());
};
depth.increment()?;
let envelope_size = 8;
let bytes_len = len * envelope_size;
let offset = decoder.out_of_line_offset(bytes_len)?;
// Decode the envelope for each type.
let mut _next_ordinal_to_read = 0;
let mut next_offset = offset;
let end_offset = offset + bytes_len;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
// Decode unknown envelopes for gaps in ordinals.
while _next_ordinal_to_read < 1 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.x.get_or_insert_with(|| {
fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
});
fidl::decode!(
u32,
fidl::encoding::DefaultFuchsiaResourceDialect,
val_ref,
decoder,
inner_offset,
inner_depth
)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
// Decode the remaining unknown envelopes.
while next_offset < end_offset {
_next_ordinal_to_read += 1;
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
next_offset += envelope_size;
}
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for Union {
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::TypeMarker for Union {
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 fidl::encoding::Encode<Union, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut Union
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Union>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
Union::X(ref val) => fidl::encoding::encode_in_envelope::<
u32,
fidl::encoding::DefaultFuchsiaResourceDialect,
>(
<u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
Union::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Union {
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
#[allow(unused_variables)]
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
let (ordinal, inlined, num_bytes, num_handles) =
fidl::encoding::decode_union_inline_portion(decoder, offset)?;
let member_inline_size = match ordinal {
1 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
0 => return Err(fidl::Error::UnknownUnionTag),
_ => num_bytes as usize,
};
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let _inner_offset;
if inlined {
decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
_inner_offset = offset + 8;
} else {
depth.increment()?;
_inner_offset = decoder.out_of_line_offset(member_inline_size)?;
}
match ordinal {
1 => {
#[allow(irrefutable_let_patterns)]
if let Union::X(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = Union::X(fidl::new_empty!(
u32,
fidl::encoding::DefaultFuchsiaResourceDialect
));
}
#[allow(irrefutable_let_patterns)]
if let Union::X(ref mut val) = self {
fidl::decode!(
u32,
fidl::encoding::DefaultFuchsiaResourceDialect,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = Union::__SourceBreaking { unknown_ordinal: ordinal };
}
}
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
Ok(())
}
}
}