#![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 type ActionName = String;
#[derive(Clone, Debug, PartialEq)]
pub struct ActionIteratorGetNextResponse {
pub actions: Vec<Action>,
}
impl fidl::Persistable for ActionIteratorGetNextResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ActorGetActionsResponse {
pub iterator: fidl::endpoints::ClientEnd<ActionIteratorMarker>,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ActorGetActionsResponse {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ActorRunRequest {
pub action_name: String,
pub seed: u64,
}
impl fidl::Persistable for ActorRunRequest {}
#[derive(Clone, Debug, PartialEq)]
pub struct ActorRunResponse {
pub error: Option<Box<Error>>,
}
impl fidl::Persistable for ActorRunResponse {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Action {
pub name: Option<String>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for Action {}
#[derive(Clone, Debug)]
pub enum Error {
ErrorString(String),
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u64 },
}
#[macro_export]
macro_rules! ErrorUnknown {
() => {
_
};
}
impl PartialEq for Error {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::ErrorString(x), Self::ErrorString(y)) => *x == *y,
_ => false,
}
}
}
impl Error {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::ErrorString(_) => 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::Persistable for Error {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ActionIteratorMarker;
impl fidl::endpoints::ProtocolMarker for ActionIteratorMarker {
type Proxy = ActionIteratorProxy;
type RequestStream = ActionIteratorRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = ActionIteratorSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) ActionIterator";
}
pub trait ActionIteratorProxyInterface: Send + Sync {
type GetNextResponseFut: std::future::Future<Output = Result<Vec<Action>, fidl::Error>> + Send;
fn r#get_next(&self) -> Self::GetNextResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct ActionIteratorSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for ActionIteratorSynchronousProxy {
type Proxy = ActionIteratorProxy;
type Protocol = ActionIteratorMarker;
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 ActionIteratorSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <ActionIteratorMarker 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<ActionIteratorEvent, fidl::Error> {
ActionIteratorEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#get_next(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<Vec<Action>, fidl::Error> {
let _response =
self.client.send_query::<fidl::encoding::EmptyPayload, ActionIteratorGetNextResponse>(
(),
0x3a6cfa20518e766a,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.actions)
}
}
#[derive(Debug, Clone)]
pub struct ActionIteratorProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for ActionIteratorProxy {
type Protocol = ActionIteratorMarker;
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 ActionIteratorProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <ActionIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> ActionIteratorEventStream {
ActionIteratorEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#get_next(
&self,
) -> fidl::client::QueryResponseFut<Vec<Action>, fidl::encoding::DefaultFuchsiaResourceDialect>
{
ActionIteratorProxyInterface::r#get_next(self)
}
}
impl ActionIteratorProxyInterface for ActionIteratorProxy {
type GetNextResponseFut =
fidl::client::QueryResponseFut<Vec<Action>, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#get_next(&self) -> Self::GetNextResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<Vec<Action>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
ActionIteratorGetNextResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x3a6cfa20518e766a,
>(_buf?)?;
Ok(_response.actions)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Action>>(
(),
0x3a6cfa20518e766a,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct ActionIteratorEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for ActionIteratorEventStream {}
impl futures::stream::FusedStream for ActionIteratorEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for ActionIteratorEventStream {
type Item = Result<ActionIteratorEvent, 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(ActionIteratorEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum ActionIteratorEvent {}
impl ActionIteratorEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<ActionIteratorEvent, 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:
<ActionIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct ActionIteratorRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for ActionIteratorRequestStream {}
impl futures::stream::FusedStream for ActionIteratorRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for ActionIteratorRequestStream {
type Protocol = ActionIteratorMarker;
type ControlHandle = ActionIteratorControlHandle;
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 {
ActionIteratorControlHandle { 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 ActionIteratorRequestStream {
type Item = Result<ActionIteratorRequest, 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 ActionIteratorRequestStream 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 {
0x3a6cfa20518e766a => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
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 =
ActionIteratorControlHandle { inner: this.inner.clone() };
Ok(ActionIteratorRequest::GetNext {
responder: ActionIteratorGetNextResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<ActionIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum ActionIteratorRequest {
GetNext { responder: ActionIteratorGetNextResponder },
}
impl ActionIteratorRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_get_next(self) -> Option<(ActionIteratorGetNextResponder)> {
if let ActionIteratorRequest::GetNext { responder } = self {
Some((responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
ActionIteratorRequest::GetNext { .. } => "get_next",
}
}
}
#[derive(Debug, Clone)]
pub struct ActionIteratorControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for ActionIteratorControlHandle {
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 ActionIteratorControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct ActionIteratorGetNextResponder {
control_handle: std::mem::ManuallyDrop<ActionIteratorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for ActionIteratorGetNextResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for ActionIteratorGetNextResponder {
type ControlHandle = ActionIteratorControlHandle;
fn control_handle(&self) -> &ActionIteratorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl ActionIteratorGetNextResponder {
pub fn send(self, mut actions: &[Action]) -> Result<(), fidl::Error> {
let _result = self.send_raw(actions);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut actions: &[Action]) -> Result<(), fidl::Error> {
let _result = self.send_raw(actions);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut actions: &[Action]) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<ActionIteratorGetNextResponse>(
(actions,),
self.tx_id,
0x3a6cfa20518e766a,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ActorMarker;
impl fidl::endpoints::ProtocolMarker for ActorMarker {
type Proxy = ActorProxy;
type RequestStream = ActorRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = ActorSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.stresstest.Actor";
}
impl fidl::endpoints::DiscoverableProtocolMarker for ActorMarker {}
pub trait ActorProxyInterface: Send + Sync {
type GetActionsResponseFut: std::future::Future<
Output = Result<fidl::endpoints::ClientEnd<ActionIteratorMarker>, fidl::Error>,
> + Send;
fn r#get_actions(&self) -> Self::GetActionsResponseFut;
type RunResponseFut: std::future::Future<Output = Result<Option<Box<Error>>, fidl::Error>>
+ Send;
fn r#run(&self, action_name: &str, seed: u64) -> Self::RunResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct ActorSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for ActorSynchronousProxy {
type Proxy = ActorProxy;
type Protocol = ActorMarker;
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 ActorSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <ActorMarker 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<ActorEvent, fidl::Error> {
ActorEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#get_actions(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<fidl::endpoints::ClientEnd<ActionIteratorMarker>, fidl::Error> {
let _response =
self.client.send_query::<fidl::encoding::EmptyPayload, ActorGetActionsResponse>(
(),
0x21b890f66d9d9cff,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.iterator)
}
pub fn r#run(
&self,
mut action_name: &str,
mut seed: u64,
___deadline: zx::MonotonicInstant,
) -> Result<Option<Box<Error>>, fidl::Error> {
let _response = self.client.send_query::<ActorRunRequest, ActorRunResponse>(
(action_name, seed),
0x28a8ff83256eef02,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.error)
}
}
#[derive(Debug, Clone)]
pub struct ActorProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for ActorProxy {
type Protocol = ActorMarker;
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 ActorProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <ActorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> ActorEventStream {
ActorEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#get_actions(
&self,
) -> fidl::client::QueryResponseFut<
fidl::endpoints::ClientEnd<ActionIteratorMarker>,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
ActorProxyInterface::r#get_actions(self)
}
pub fn r#run(
&self,
mut action_name: &str,
mut seed: u64,
) -> fidl::client::QueryResponseFut<
Option<Box<Error>>,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
ActorProxyInterface::r#run(self, action_name, seed)
}
}
impl ActorProxyInterface for ActorProxy {
type GetActionsResponseFut = fidl::client::QueryResponseFut<
fidl::endpoints::ClientEnd<ActionIteratorMarker>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#get_actions(&self) -> Self::GetActionsResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<fidl::endpoints::ClientEnd<ActionIteratorMarker>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
ActorGetActionsResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x21b890f66d9d9cff,
>(_buf?)?;
Ok(_response.iterator)
}
self.client.send_query_and_decode::<
fidl::encoding::EmptyPayload,
fidl::endpoints::ClientEnd<ActionIteratorMarker>,
>(
(),
0x21b890f66d9d9cff,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type RunResponseFut = fidl::client::QueryResponseFut<
Option<Box<Error>>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#run(&self, mut action_name: &str, mut seed: u64) -> Self::RunResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<Option<Box<Error>>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
ActorRunResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x28a8ff83256eef02,
>(_buf?)?;
Ok(_response.error)
}
self.client.send_query_and_decode::<ActorRunRequest, Option<Box<Error>>>(
(action_name, seed),
0x28a8ff83256eef02,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct ActorEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for ActorEventStream {}
impl futures::stream::FusedStream for ActorEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for ActorEventStream {
type Item = Result<ActorEvent, 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(ActorEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum ActorEvent {}
impl ActorEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<ActorEvent, 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: <ActorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct ActorRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for ActorRequestStream {}
impl futures::stream::FusedStream for ActorRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for ActorRequestStream {
type Protocol = ActorMarker;
type ControlHandle = ActorControlHandle;
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 {
ActorControlHandle { 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 ActorRequestStream {
type Item = Result<ActorRequest, 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 ActorRequestStream 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 {
0x21b890f66d9d9cff => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
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 = ActorControlHandle { inner: this.inner.clone() };
Ok(ActorRequest::GetActions {
responder: ActorGetActionsResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x28a8ff83256eef02 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
ActorRunRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActorRunRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = ActorControlHandle { inner: this.inner.clone() };
Ok(ActorRequest::Run {
action_name: req.action_name,
seed: req.seed,
responder: ActorRunResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <ActorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum ActorRequest {
GetActions { responder: ActorGetActionsResponder },
Run { action_name: String, seed: u64, responder: ActorRunResponder },
}
impl ActorRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_get_actions(self) -> Option<(ActorGetActionsResponder)> {
if let ActorRequest::GetActions { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_run(self) -> Option<(String, u64, ActorRunResponder)> {
if let ActorRequest::Run { action_name, seed, responder } = self {
Some((action_name, seed, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
ActorRequest::GetActions { .. } => "get_actions",
ActorRequest::Run { .. } => "run",
}
}
}
#[derive(Debug, Clone)]
pub struct ActorControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for ActorControlHandle {
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 ActorControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct ActorGetActionsResponder {
control_handle: std::mem::ManuallyDrop<ActorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for ActorGetActionsResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for ActorGetActionsResponder {
type ControlHandle = ActorControlHandle;
fn control_handle(&self) -> &ActorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl ActorGetActionsResponder {
pub fn send(
self,
mut iterator: fidl::endpoints::ClientEnd<ActionIteratorMarker>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(iterator);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut iterator: fidl::endpoints::ClientEnd<ActionIteratorMarker>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(iterator);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut iterator: fidl::endpoints::ClientEnd<ActionIteratorMarker>,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<ActorGetActionsResponse>(
(iterator,),
self.tx_id,
0x21b890f66d9d9cff,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct ActorRunResponder {
control_handle: std::mem::ManuallyDrop<ActorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for ActorRunResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for ActorRunResponder {
type ControlHandle = ActorControlHandle;
fn control_handle(&self) -> &ActorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl ActorRunResponder {
pub fn send(self, mut error: Option<&Error>) -> Result<(), fidl::Error> {
let _result = self.send_raw(error);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut error: Option<&Error>) -> Result<(), fidl::Error> {
let _result = self.send_raw(error);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut error: Option<&Error>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<ActorRunResponse>(
(error,),
self.tx_id,
0x28a8ff83256eef02,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
impl fidl::encoding::ValueTypeMarker for ActionIteratorGetNextResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ActionIteratorGetNextResponse {
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<ActionIteratorGetNextResponse, D>
for &ActionIteratorGetNextResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ActionIteratorGetNextResponse>(offset);
fidl::encoding::Encode::<ActionIteratorGetNextResponse, D>::encode(
(
<fidl::encoding::UnboundedVector<Action> as fidl::encoding::ValueTypeMarker>::borrow(&self.actions),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Action>, D>,
> fidl::encoding::Encode<ActionIteratorGetNextResponse, 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::<ActionIteratorGetNextResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for ActionIteratorGetNextResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { actions: fidl::new_empty!(fidl::encoding::UnboundedVector<Action>, 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::UnboundedVector<Action>,
D,
&mut self.actions,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for ActorGetActionsResponse {
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 ActorGetActionsResponse {
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
}
}
unsafe impl
fidl::encoding::Encode<
ActorGetActionsResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut ActorGetActionsResponse
{
#[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::<ActorGetActionsResponse>(offset);
fidl::encoding::Encode::<ActorGetActionsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
(
<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ActionIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ActionIteratorMarker>>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<
ActorGetActionsResponse,
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::<ActorGetActionsResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for ActorGetActionsResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self {
iterator: fidl::new_empty!(
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ActionIteratorMarker>>,
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);
fidl::decode!(
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ActionIteratorMarker>>,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.iterator,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for ActorRunRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ActorRunRequest {
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
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ActorRunRequest, D>
for &ActorRunRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ActorRunRequest>(offset);
fidl::encoding::Encode::<ActorRunRequest, D>::encode(
(
<fidl::encoding::BoundedString<512> as fidl::encoding::ValueTypeMarker>::borrow(
&self.action_name,
),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.seed),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::BoundedString<512>, D>,
T1: fidl::encoding::Encode<u64, D>,
> fidl::encoding::Encode<ActorRunRequest, D> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ActorRunRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 16, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ActorRunRequest {
#[inline(always)]
fn new_empty() -> Self {
Self {
action_name: fidl::new_empty!(fidl::encoding::BoundedString<512>, D),
seed: fidl::new_empty!(u64, 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<512>,
D,
&mut self.action_name,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(u64, D, &mut self.seed, decoder, offset + 16, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for ActorRunResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ActorRunResponse {
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<ActorRunResponse, D>
for &ActorRunResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ActorRunResponse>(offset);
fidl::encoding::Encode::<ActorRunResponse, D>::encode(
(
<fidl::encoding::OptionalUnion<Error> as fidl::encoding::ValueTypeMarker>::borrow(&self.error),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::OptionalUnion<Error>, D>,
> fidl::encoding::Encode<ActorRunResponse, 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::<ActorRunResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ActorRunResponse {
#[inline(always)]
fn new_empty() -> Self {
Self { error: fidl::new_empty!(fidl::encoding::OptionalUnion<Error>, 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::OptionalUnion<Error>,
D,
&mut self.error,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl Action {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.name {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for Action {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Action {
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<Action, D> for &Action {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Action>(offset);
let max_ordinal: u64 = self.max_ordinal_present();
encoder.write_num(max_ordinal, offset);
encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
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(());
}
let cur_offset: usize = (1 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<512>, D>(
self.name.as_ref().map(
<fidl::encoding::BoundedString<512> as fidl::encoding::ValueTypeMarker>::borrow,
),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Action {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
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,
};
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)?;
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(());
}
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 =
<fidl::encoding::BoundedString<512> 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
.name
.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<512>, D));
fidl::decode!(
fidl::encoding::BoundedString<512>,
D,
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;
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::ValueTypeMarker for Error {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Error {
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<Error, D> for &Error {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Error>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
Error::ErrorString(ref val) => fidl::encoding::encode_in_envelope::<
fidl::encoding::BoundedString<512>,
D,
>(
<fidl::encoding::BoundedString<512> as fidl::encoding::ValueTypeMarker>::borrow(
val,
),
encoder,
offset + 8,
_depth,
),
Error::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
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 => {
<fidl::encoding::BoundedString<512> 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 Error::ErrorString(_) = self {
} else {
*self = Error::ErrorString(fidl::new_empty!(
fidl::encoding::BoundedString<512>,
D
));
}
#[allow(irrefutable_let_patterns)]
if let Error::ErrorString(ref mut val) = self {
fidl::decode!(
fidl::encoding::BoundedString<512>,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = Error::__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(())
}
}
}