#![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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum Error {
Unsupported,
InvalidArguments,
NotFound,
AlreadyExists,
BadRule,
RetryExceeded,
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u32 },
}
#[macro_export]
macro_rules! ErrorUnknown {
() => {
_
};
}
impl Error {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
0 => Some(Self::Unsupported),
1 => Some(Self::InvalidArguments),
2 => Some(Self::NotFound),
3 => Some(Self::AlreadyExists),
4 => Some(Self::BadRule),
5 => Some(Self::RetryExceeded),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
0 => Self::Unsupported,
1 => Self::InvalidArguments,
2 => Self::NotFound,
3 => Self::AlreadyExists,
4 => Self::BadRule,
5 => Self::RetryExceeded,
unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
}
}
#[inline]
pub fn unknown() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
}
#[inline]
pub const fn into_primitive(self) -> u32 {
match self {
Self::Unsupported => 0,
Self::InvalidArguments => 1,
Self::NotFound => 2,
Self::AlreadyExists => 3,
Self::BadRule => 4,
Self::RetryExceeded => 5,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { unknown_ordinal: _ } => true,
_ => false,
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct ControlConfig {
pub input_interface: u64,
pub src_subnet: fidl_fuchsia_net::Subnet,
pub output_interface: u64,
}
impl fidl::Persistable for ControlConfig {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ControlSetEnabledRequest {
pub enabled: bool,
}
impl fidl::Persistable for ControlSetEnabledRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ControlSetEnabledResponse {
pub was_enabled: bool,
}
impl fidl::Persistable for ControlSetEnabledResponse {}
#[derive(Debug, PartialEq)]
pub struct FactoryCreateRequest {
pub config: ControlConfig,
pub control: fidl::endpoints::ServerEnd<ControlMarker>,
}
impl fidl::Standalone for FactoryCreateRequest {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ControlMarker;
impl fidl::endpoints::ProtocolMarker for ControlMarker {
type Proxy = ControlProxy;
type RequestStream = ControlRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = ControlSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) Control";
}
pub type ControlSetEnabledResult = Result<bool, Error>;
pub trait ControlProxyInterface: Send + Sync {
type SetEnabledResponseFut: std::future::Future<Output = Result<ControlSetEnabledResult, fidl::Error>>
+ Send;
fn r#set_enabled(&self, enabled: bool) -> Self::SetEnabledResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct ControlSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
type Proxy = ControlProxy;
type Protocol = ControlMarker;
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 ControlSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <ControlMarker 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<ControlEvent, fidl::Error> {
ControlEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#set_enabled(
&self,
mut enabled: bool,
___deadline: zx::Time,
) -> Result<ControlSetEnabledResult, fidl::Error> {
let _response = self.client.send_query::<
ControlSetEnabledRequest,
fidl::encoding::ResultType<ControlSetEnabledResponse, Error>,
>(
(enabled,),
0x13b7914afdb709a6,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x.was_enabled))
}
}
#[derive(Debug, Clone)]
pub struct ControlProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for ControlProxy {
type Protocol = ControlMarker;
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 ControlProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> ControlEventStream {
ControlEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#set_enabled(
&self,
mut enabled: bool,
) -> fidl::client::QueryResponseFut<ControlSetEnabledResult> {
ControlProxyInterface::r#set_enabled(self, enabled)
}
}
impl ControlProxyInterface for ControlProxy {
type SetEnabledResponseFut = fidl::client::QueryResponseFut<ControlSetEnabledResult>;
fn r#set_enabled(&self, mut enabled: bool) -> Self::SetEnabledResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<ControlSetEnabledResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<ControlSetEnabledResponse, Error>,
0x13b7914afdb709a6,
>(_buf?)?;
Ok(_response.map(|x| x.was_enabled))
}
self.client.send_query_and_decode::<ControlSetEnabledRequest, ControlSetEnabledResult>(
(enabled,),
0x13b7914afdb709a6,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct ControlEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for ControlEventStream {}
impl futures::stream::FusedStream for ControlEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for ControlEventStream {
type Item = Result<ControlEvent, 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(ControlEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum ControlEvent {}
impl ControlEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<ControlEvent, 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: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct ControlRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for ControlRequestStream {}
impl futures::stream::FusedStream for ControlRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for ControlRequestStream {
type Protocol = ControlMarker;
type ControlHandle = ControlControlHandle;
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 {
ControlControlHandle { 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 ControlRequestStream {
type Item = Result<ControlRequest, 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 ControlRequestStream 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 {
0x13b7914afdb709a6 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(ControlSetEnabledRequest);
fidl::encoding::Decoder::decode_into::<ControlSetEnabledRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = ControlControlHandle { inner: this.inner.clone() };
Ok(ControlRequest::SetEnabled {
enabled: req.enabled,
responder: ControlSetEnabledResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum ControlRequest {
SetEnabled { enabled: bool, responder: ControlSetEnabledResponder },
}
impl ControlRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_set_enabled(self) -> Option<(bool, ControlSetEnabledResponder)> {
if let ControlRequest::SetEnabled { enabled, responder } = self {
Some((enabled, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
ControlRequest::SetEnabled { .. } => "set_enabled",
}
}
}
#[derive(Debug, Clone)]
pub struct ControlControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for ControlControlHandle {
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 ControlControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct ControlSetEnabledResponder {
control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for ControlSetEnabledResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for ControlSetEnabledResponder {
type ControlHandle = ControlControlHandle;
fn control_handle(&self) -> &ControlControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl ControlSetEnabledResponder {
pub fn send(self, mut result: Result<bool, Error>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<bool, Error>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<bool, Error>) -> Result<(), fidl::Error> {
self.control_handle
.inner
.send::<fidl::encoding::ResultType<ControlSetEnabledResponse, Error>>(
result.map(|was_enabled| (was_enabled,)),
self.tx_id,
0x13b7914afdb709a6,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct FactoryMarker;
impl fidl::endpoints::ProtocolMarker for FactoryMarker {
type Proxy = FactoryProxy;
type RequestStream = FactoryRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = FactorySynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.net.masquerade.Factory";
}
impl fidl::endpoints::DiscoverableProtocolMarker for FactoryMarker {}
pub type FactoryCreateResult = Result<(), Error>;
pub trait FactoryProxyInterface: Send + Sync {
type CreateResponseFut: std::future::Future<Output = Result<FactoryCreateResult, fidl::Error>>
+ Send;
fn r#create(
&self,
config: &ControlConfig,
control: fidl::endpoints::ServerEnd<ControlMarker>,
) -> Self::CreateResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct FactorySynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for FactorySynchronousProxy {
type Proxy = FactoryProxy;
type Protocol = FactoryMarker;
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 FactorySynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <FactoryMarker 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<FactoryEvent, fidl::Error> {
FactoryEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#create(
&self,
mut config: &ControlConfig,
mut control: fidl::endpoints::ServerEnd<ControlMarker>,
___deadline: zx::Time,
) -> Result<FactoryCreateResult, fidl::Error> {
let _response = self.client.send_query::<FactoryCreateRequest, fidl::encoding::ResultType<
fidl::encoding::EmptyStruct,
Error,
>>(
(config, control),
0x65f64a124fd0170e,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x))
}
}
#[derive(Debug, Clone)]
pub struct FactoryProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for FactoryProxy {
type Protocol = FactoryMarker;
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 FactoryProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> FactoryEventStream {
FactoryEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#create(
&self,
mut config: &ControlConfig,
mut control: fidl::endpoints::ServerEnd<ControlMarker>,
) -> fidl::client::QueryResponseFut<FactoryCreateResult> {
FactoryProxyInterface::r#create(self, config, control)
}
}
impl FactoryProxyInterface for FactoryProxy {
type CreateResponseFut = fidl::client::QueryResponseFut<FactoryCreateResult>;
fn r#create(
&self,
mut config: &ControlConfig,
mut control: fidl::endpoints::ServerEnd<ControlMarker>,
) -> Self::CreateResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<FactoryCreateResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
0x65f64a124fd0170e,
>(_buf?)?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<FactoryCreateRequest, FactoryCreateResult>(
(config, control),
0x65f64a124fd0170e,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct FactoryEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for FactoryEventStream {}
impl futures::stream::FusedStream for FactoryEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for FactoryEventStream {
type Item = Result<FactoryEvent, 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(FactoryEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum FactoryEvent {}
impl FactoryEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<FactoryEvent, 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: <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct FactoryRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for FactoryRequestStream {}
impl futures::stream::FusedStream for FactoryRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for FactoryRequestStream {
type Protocol = FactoryMarker;
type ControlHandle = FactoryControlHandle;
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 {
FactoryControlHandle { 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 FactoryRequestStream {
type Item = Result<FactoryRequest, 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 FactoryRequestStream 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 {
0x65f64a124fd0170e => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(FactoryCreateRequest);
fidl::encoding::Decoder::decode_into::<FactoryCreateRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = FactoryControlHandle { inner: this.inner.clone() };
Ok(FactoryRequest::Create {
config: req.config,
control: req.control,
responder: FactoryCreateResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum FactoryRequest {
Create {
config: ControlConfig,
control: fidl::endpoints::ServerEnd<ControlMarker>,
responder: FactoryCreateResponder,
},
}
impl FactoryRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_create(
self,
) -> Option<(ControlConfig, fidl::endpoints::ServerEnd<ControlMarker>, FactoryCreateResponder)>
{
if let FactoryRequest::Create { config, control, responder } = self {
Some((config, control, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
FactoryRequest::Create { .. } => "create",
}
}
}
#[derive(Debug, Clone)]
pub struct FactoryControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for FactoryControlHandle {
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 FactoryControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct FactoryCreateResponder {
control_handle: std::mem::ManuallyDrop<FactoryControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for FactoryCreateResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for FactoryCreateResponder {
type ControlHandle = FactoryControlHandle;
fn control_handle(&self) -> &FactoryControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl FactoryCreateResponder {
pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
self.control_handle
.inner
.send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
result,
self.tx_id,
0x65f64a124fd0170e,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for Error {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u32>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u32>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
false
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for Error {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
*value
}
}
unsafe impl fidl::encoding::Encode<Self> for Error {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl fidl::encoding::Decode<Self> for Error {
#[inline(always)]
fn new_empty() -> Self {
Self::unknown()
}
#[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 prim = decoder.read_num::<u32>(offset);
*self = Self::from_primitive_allow_unknown(prim);
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for ControlConfig {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
40
}
}
impl fidl::encoding::ValueTypeMarker for ControlConfig {
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<ControlConfig> for &ControlConfig {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ControlConfig>(offset);
fidl::encoding::Encode::<ControlConfig>::encode(
(
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.input_interface),
<fidl_fuchsia_net::Subnet as fidl::encoding::ValueTypeMarker>::borrow(
&self.src_subnet,
),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.output_interface),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<u64>,
T1: fidl::encoding::Encode<fidl_fuchsia_net::Subnet>,
T2: fidl::encoding::Encode<u64>,
> fidl::encoding::Encode<ControlConfig> for (T0, T1, T2)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ControlConfig>(offset);
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
self.2.encode(encoder, offset + 32, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for ControlConfig {
#[inline(always)]
fn new_empty() -> Self {
Self {
input_interface: fidl::new_empty!(u64),
src_subnet: fidl::new_empty!(fidl_fuchsia_net::Subnet),
output_interface: fidl::new_empty!(u64),
}
}
#[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!(u64, &mut self.input_interface, decoder, offset + 0, _depth)?;
fidl::decode!(
fidl_fuchsia_net::Subnet,
&mut self.src_subnet,
decoder,
offset + 8,
_depth
)?;
fidl::decode!(u64, &mut self.output_interface, decoder, offset + 32, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for ControlSetEnabledRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
1
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
1
}
}
impl fidl::encoding::ValueTypeMarker for ControlSetEnabledRequest {
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<ControlSetEnabledRequest> for &ControlSetEnabledRequest {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ControlSetEnabledRequest>(offset);
fidl::encoding::Encode::<ControlSetEnabledRequest>::encode(
(<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enabled),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<bool>> fidl::encoding::Encode<ControlSetEnabledRequest>
for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ControlSetEnabledRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for ControlSetEnabledRequest {
#[inline(always)]
fn new_empty() -> Self {
Self { enabled: fidl::new_empty!(bool) }
}
#[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!(bool, &mut self.enabled, decoder, offset + 0, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for ControlSetEnabledResponse {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
1
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
1
}
}
impl fidl::encoding::ValueTypeMarker for ControlSetEnabledResponse {
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<ControlSetEnabledResponse> for &ControlSetEnabledResponse {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ControlSetEnabledResponse>(offset);
fidl::encoding::Encode::<ControlSetEnabledResponse>::encode(
(<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.was_enabled),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<bool>> fidl::encoding::Encode<ControlSetEnabledResponse>
for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ControlSetEnabledResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for ControlSetEnabledResponse {
#[inline(always)]
fn new_empty() -> Self {
Self { was_enabled: fidl::new_empty!(bool) }
}
#[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!(bool, &mut self.was_enabled, decoder, offset + 0, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for FactoryCreateRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
48
}
}
impl fidl::encoding::ResourceTypeMarker for FactoryCreateRequest {
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<FactoryCreateRequest> for &mut FactoryCreateRequest {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
fidl::encoding::Encode::<FactoryCreateRequest>::encode(
(
<ControlConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.control),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<ControlConfig>,
T1: fidl::encoding::Encode<
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
>,
> fidl::encoding::Encode<FactoryCreateRequest> 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::<FactoryCreateRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 40, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for FactoryCreateRequest {
#[inline(always)]
fn new_empty() -> Self {
Self {
config: fidl::new_empty!(ControlConfig),
control: fidl::new_empty!(
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>
),
}
}
#[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(40) };
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 + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(ControlConfig, &mut self.config, decoder, offset + 0, _depth)?;
fidl::decode!(
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
&mut self.control,
decoder,
offset + 40,
_depth
)?;
Ok(())
}
}
}