#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use bitflags::bitflags;
use fidl::client::QueryResponseFut;
use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
use fidl::endpoints::{ControlHandle as _, Responder as _};
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
pub const MAX_GUEST_NAME_LENGTH: u64 = 32;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum ControllerCreateGuestError {
AlreadyRunning = 1,
LaunchFailed = 2,
AttachFailed = 3,
}
impl ControllerCreateGuestError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::AlreadyRunning),
2 => Some(Self::LaunchFailed),
3 => Some(Self::AttachFailed),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u32 {
self as u32
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Debug, PartialEq)]
pub struct ControllerCreateGuestRequest {
pub name: String,
pub network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
pub mac: Option<Box<fidl_fuchsia_net::MacAddress>>,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
for ControllerCreateGuestRequest
{
}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ControllerCreateGuestResponse {
pub s: fidl::endpoints::ClientEnd<GuestMarker>,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
for ControllerCreateGuestResponse
{
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ControllerMarker;
impl fidl::endpoints::ProtocolMarker for ControllerMarker {
type Proxy = ControllerProxy;
type RequestStream = ControllerRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = ControllerSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.netemul.guest.Controller";
}
impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
pub type ControllerCreateGuestResult =
Result<fidl::endpoints::ClientEnd<GuestMarker>, ControllerCreateGuestError>;
pub trait ControllerProxyInterface: Send + Sync {
type CreateGuestResponseFut: std::future::Future<Output = Result<ControllerCreateGuestResult, fidl::Error>>
+ Send;
fn r#create_guest(
&self,
name: &str,
network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
mac: Option<&fidl_fuchsia_net::MacAddress>,
) -> Self::CreateGuestResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct ControllerSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
type Proxy = ControllerProxy;
type Protocol = ControllerMarker;
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 ControllerSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <ControllerMarker 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<ControllerEvent, fidl::Error> {
ControllerEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#create_guest(
&self,
mut name: &str,
mut network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
mut mac: Option<&fidl_fuchsia_net::MacAddress>,
___deadline: zx::MonotonicInstant,
) -> Result<ControllerCreateGuestResult, fidl::Error> {
let _response =
self.client.send_query::<ControllerCreateGuestRequest, fidl::encoding::ResultType<
ControllerCreateGuestResponse,
ControllerCreateGuestError,
>>(
(name, network, mac),
0x5c49cf5272f818c0,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x.s))
}
}
#[derive(Debug, Clone)]
pub struct ControllerProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for ControllerProxy {
type Protocol = ControllerMarker;
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 ControllerProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> ControllerEventStream {
ControllerEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#create_guest(
&self,
mut name: &str,
mut network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
mut mac: Option<&fidl_fuchsia_net::MacAddress>,
) -> fidl::client::QueryResponseFut<
ControllerCreateGuestResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
ControllerProxyInterface::r#create_guest(self, name, network, mac)
}
}
impl ControllerProxyInterface for ControllerProxy {
type CreateGuestResponseFut = fidl::client::QueryResponseFut<
ControllerCreateGuestResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#create_guest(
&self,
mut name: &str,
mut network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
mut mac: Option<&fidl_fuchsia_net::MacAddress>,
) -> Self::CreateGuestResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<ControllerCreateGuestResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<
ControllerCreateGuestResponse,
ControllerCreateGuestError,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x5c49cf5272f818c0,
>(_buf?)?;
Ok(_response.map(|x| x.s))
}
self.client
.send_query_and_decode::<ControllerCreateGuestRequest, ControllerCreateGuestResult>(
(name, network, mac),
0x5c49cf5272f818c0,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct ControllerEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for ControllerEventStream {}
impl futures::stream::FusedStream for ControllerEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for ControllerEventStream {
type Item = Result<ControllerEvent, 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(ControllerEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum ControllerEvent {}
impl ControllerEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<ControllerEvent, 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: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct ControllerRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for ControllerRequestStream {}
impl futures::stream::FusedStream for ControllerRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for ControllerRequestStream {
type Protocol = ControllerMarker;
type ControlHandle = ControllerControlHandle;
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 {
ControllerControlHandle { 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 ControllerRequestStream {
type Item = Result<ControllerRequest, 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 ControllerRequestStream 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 {
0x5c49cf5272f818c0 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
ControllerCreateGuestRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerCreateGuestRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = ControllerControlHandle { inner: this.inner.clone() };
Ok(ControllerRequest::CreateGuest {
name: req.name,
network: req.network,
mac: req.mac,
responder: ControllerCreateGuestResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum ControllerRequest {
CreateGuest {
name: String,
network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
mac: Option<Box<fidl_fuchsia_net::MacAddress>>,
responder: ControllerCreateGuestResponder,
},
}
impl ControllerRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_create_guest(
self,
) -> Option<(
String,
fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
Option<Box<fidl_fuchsia_net::MacAddress>>,
ControllerCreateGuestResponder,
)> {
if let ControllerRequest::CreateGuest { name, network, mac, responder } = self {
Some((name, network, mac, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
ControllerRequest::CreateGuest { .. } => "create_guest",
}
}
}
#[derive(Debug, Clone)]
pub struct ControllerControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for ControllerControlHandle {
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 ControllerControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct ControllerCreateGuestResponder {
control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for ControllerCreateGuestResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for ControllerCreateGuestResponder {
type ControlHandle = ControllerControlHandle;
fn control_handle(&self) -> &ControllerControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl ControllerCreateGuestResponder {
pub fn send(
self,
mut result: Result<fidl::endpoints::ClientEnd<GuestMarker>, ControllerCreateGuestError>,
) -> 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<fidl::endpoints::ClientEnd<GuestMarker>, ControllerCreateGuestError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut result: Result<fidl::endpoints::ClientEnd<GuestMarker>, ControllerCreateGuestError>,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::ResultType<
ControllerCreateGuestResponse,
ControllerCreateGuestError,
>>(
result.map(|s| (s,)),
self.tx_id,
0x5c49cf5272f818c0,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct GuestMarker;
impl fidl::endpoints::ProtocolMarker for GuestMarker {
type Proxy = GuestProxy;
type RequestStream = GuestRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = GuestSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) Guest";
}
pub trait GuestProxyInterface: Send + Sync {
type PutFileResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
fn r#put_file(
&self,
local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
remote_path: &str,
) -> Self::PutFileResponseFut;
type GetFileResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
fn r#get_file(
&self,
remote_path: &str,
local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
) -> Self::GetFileResponseFut;
fn r#execute_command(
&self,
command: &str,
env: &[fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable],
stdin: Option<fidl::Socket>,
stdout: Option<fidl::Socket>,
stderr: Option<fidl::Socket>,
command_listener: fidl::endpoints::ServerEnd<
fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
>,
) -> Result<(), fidl::Error>;
type ShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#shutdown(&self) -> Self::ShutdownResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct GuestSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for GuestSynchronousProxy {
type Proxy = GuestProxy;
type Protocol = GuestMarker;
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 GuestSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <GuestMarker 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<GuestEvent, fidl::Error> {
GuestEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#put_file(
&self,
mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
mut remote_path: &str,
___deadline: zx::MonotonicInstant,
) -> Result<i32, fidl::Error> {
let _response = self.client.send_query::<
fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileRequest,
fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileResponse,
>(
(local_file, remote_path,),
0x223bc20da4a7cddd,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.status)
}
pub fn r#get_file(
&self,
mut remote_path: &str,
mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
___deadline: zx::MonotonicInstant,
) -> Result<i32, fidl::Error> {
let _response = self.client.send_query::<
fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileRequest,
fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileResponse,
>(
(remote_path, local_file,),
0x7696bea472ca0f2d,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.status)
}
pub fn r#execute_command(
&self,
mut command: &str,
mut env: &[fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable],
mut stdin: Option<fidl::Socket>,
mut stdout: Option<fidl::Socket>,
mut stderr: Option<fidl::Socket>,
mut command_listener: fidl::endpoints::ServerEnd<
fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
>,
) -> Result<(), fidl::Error> {
self.client.send::<fidl_fuchsia_virtualization_guest_interaction::InteractionExecuteCommandRequest>(
(command, env, stdin, stdout, stderr, command_listener,),
0x612641220a1556d8,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
let _response =
self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
(),
0x287e71d61642d1cc,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct GuestProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for GuestProxy {
type Protocol = GuestMarker;
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 GuestProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> GuestEventStream {
GuestEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#put_file(
&self,
mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
mut remote_path: &str,
) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
GuestProxyInterface::r#put_file(self, local_file, remote_path)
}
pub fn r#get_file(
&self,
mut remote_path: &str,
mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
GuestProxyInterface::r#get_file(self, remote_path, local_file)
}
pub fn r#execute_command(
&self,
mut command: &str,
mut env: &[fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable],
mut stdin: Option<fidl::Socket>,
mut stdout: Option<fidl::Socket>,
mut stderr: Option<fidl::Socket>,
mut command_listener: fidl::endpoints::ServerEnd<
fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
>,
) -> Result<(), fidl::Error> {
GuestProxyInterface::r#execute_command(
self,
command,
env,
stdin,
stdout,
stderr,
command_listener,
)
}
pub fn r#shutdown(
&self,
) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
GuestProxyInterface::r#shutdown(self)
}
}
impl GuestProxyInterface for GuestProxy {
type PutFileResponseFut =
fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#put_file(
&self,
mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
mut remote_path: &str,
) -> Self::PutFileResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<i32, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x223bc20da4a7cddd,
>(_buf?)?;
Ok(_response.status)
}
self.client.send_query_and_decode::<
fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileRequest,
i32,
>(
(local_file, remote_path,),
0x223bc20da4a7cddd,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type GetFileResponseFut =
fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#get_file(
&self,
mut remote_path: &str,
mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
) -> Self::GetFileResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<i32, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x7696bea472ca0f2d,
>(_buf?)?;
Ok(_response.status)
}
self.client.send_query_and_decode::<
fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileRequest,
i32,
>(
(remote_path, local_file,),
0x7696bea472ca0f2d,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#execute_command(
&self,
mut command: &str,
mut env: &[fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable],
mut stdin: Option<fidl::Socket>,
mut stdout: Option<fidl::Socket>,
mut stderr: Option<fidl::Socket>,
mut command_listener: fidl::endpoints::ServerEnd<
fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
>,
) -> Result<(), fidl::Error> {
self.client.send::<fidl_fuchsia_virtualization_guest_interaction::InteractionExecuteCommandRequest>(
(command, env, stdin, stdout, stderr, command_listener,),
0x612641220a1556d8,
fidl::encoding::DynamicFlags::empty(),
)
}
type ShutdownResponseFut =
fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#shutdown(&self) -> Self::ShutdownResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x287e71d61642d1cc,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
(),
0x287e71d61642d1cc,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct GuestEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for GuestEventStream {}
impl futures::stream::FusedStream for GuestEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for GuestEventStream {
type Item = Result<GuestEvent, 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(GuestEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum GuestEvent {}
impl GuestEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<GuestEvent, 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: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct GuestRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for GuestRequestStream {}
impl futures::stream::FusedStream for GuestRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for GuestRequestStream {
type Protocol = GuestMarker;
type ControlHandle = GuestControlHandle;
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 {
GuestControlHandle { 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 GuestRequestStream {
type Item = Result<GuestRequest, 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 GuestRequestStream 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 {
0x223bc20da4a7cddd => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = GuestControlHandle { inner: this.inner.clone() };
Ok(GuestRequest::PutFile {
local_file: req.local_file,
remote_path: req.remote_path,
responder: GuestPutFileResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x7696bea472ca0f2d => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = GuestControlHandle { inner: this.inner.clone() };
Ok(GuestRequest::GetFile {
remote_path: req.remote_path,
local_file: req.local_file,
responder: GuestGetFileResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x612641220a1556d8 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(fidl_fuchsia_virtualization_guest_interaction::InteractionExecuteCommandRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_virtualization_guest_interaction::InteractionExecuteCommandRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = GuestControlHandle { inner: this.inner.clone() };
Ok(GuestRequest::ExecuteCommand {
command: req.command,
env: req.env,
stdin: req.stdin,
stdout: req.stdout,
stderr: req.stderr,
command_listener: req.command_listener,
control_handle,
})
}
0x287e71d61642d1cc => {
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 = GuestControlHandle { inner: this.inner.clone() };
Ok(GuestRequest::Shutdown {
responder: GuestShutdownResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum GuestRequest {
PutFile {
local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
remote_path: String,
responder: GuestPutFileResponder,
},
GetFile {
remote_path: String,
local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
responder: GuestGetFileResponder,
},
ExecuteCommand {
command: String,
env: Vec<fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable>,
stdin: Option<fidl::Socket>,
stdout: Option<fidl::Socket>,
stderr: Option<fidl::Socket>,
command_listener: fidl::endpoints::ServerEnd<
fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
>,
control_handle: GuestControlHandle,
},
Shutdown { responder: GuestShutdownResponder },
}
impl GuestRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_put_file(
self,
) -> Option<(
fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
String,
GuestPutFileResponder,
)> {
if let GuestRequest::PutFile { local_file, remote_path, responder } = self {
Some((local_file, remote_path, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_get_file(
self,
) -> Option<(
String,
fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
GuestGetFileResponder,
)> {
if let GuestRequest::GetFile { remote_path, local_file, responder } = self {
Some((remote_path, local_file, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_execute_command(
self,
) -> Option<(
String,
Vec<fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable>,
Option<fidl::Socket>,
Option<fidl::Socket>,
Option<fidl::Socket>,
fidl::endpoints::ServerEnd<
fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
>,
GuestControlHandle,
)> {
if let GuestRequest::ExecuteCommand {
command,
env,
stdin,
stdout,
stderr,
command_listener,
control_handle,
} = self
{
Some((command, env, stdin, stdout, stderr, command_listener, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_shutdown(self) -> Option<(GuestShutdownResponder)> {
if let GuestRequest::Shutdown { responder } = self {
Some((responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
GuestRequest::PutFile { .. } => "put_file",
GuestRequest::GetFile { .. } => "get_file",
GuestRequest::ExecuteCommand { .. } => "execute_command",
GuestRequest::Shutdown { .. } => "shutdown",
}
}
}
#[derive(Debug, Clone)]
pub struct GuestControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for GuestControlHandle {
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 GuestControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct GuestPutFileResponder {
control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for GuestPutFileResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for GuestPutFileResponder {
type ControlHandle = GuestControlHandle;
fn control_handle(&self) -> &GuestControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl GuestPutFileResponder {
pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
let _result = self.send_raw(status);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
let _result = self.send_raw(status);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
self.control_handle
.inner
.send::<fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileResponse>(
(status,),
self.tx_id,
0x223bc20da4a7cddd,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct GuestGetFileResponder {
control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for GuestGetFileResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for GuestGetFileResponder {
type ControlHandle = GuestControlHandle;
fn control_handle(&self) -> &GuestControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl GuestGetFileResponder {
pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
let _result = self.send_raw(status);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
let _result = self.send_raw(status);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
self.control_handle
.inner
.send::<fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileResponse>(
(status,),
self.tx_id,
0x7696bea472ca0f2d,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct GuestShutdownResponder {
control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for GuestShutdownResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for GuestShutdownResponder {
type ControlHandle = GuestControlHandle;
fn control_handle(&self) -> &GuestControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl GuestShutdownResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x287e71d61642d1cc,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for ControllerCreateGuestError {
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 {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for ControllerCreateGuestError {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
*value
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
for ControllerCreateGuestError
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for ControllerCreateGuestError
{
#[inline(always)]
fn new_empty() -> Self {
Self::AlreadyRunning
}
#[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);
let prim = decoder.read_num::<u32>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for ControllerCreateGuestRequest {
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 ControllerCreateGuestRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
32
}
}
unsafe impl
fidl::encoding::Encode<
ControllerCreateGuestRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut ControllerCreateGuestRequest
{
#[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::<ControllerCreateGuestRequest>(offset);
fidl::encoding::Encode::<ControllerCreateGuestRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
(
<fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.network),
<fidl::encoding::Boxed<fidl_fuchsia_net::MacAddress> as fidl::encoding::ValueTypeMarker>::borrow(&self.mac),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<
fidl::encoding::BoundedString<32>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
T1: fidl::encoding::Encode<
fidl::encoding::Endpoint<
fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
T2: fidl::encoding::Encode<
fidl::encoding::Boxed<fidl_fuchsia_net::MacAddress>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<
ControllerCreateGuestRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for (T0, T1, T2)
{
#[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::<ControllerCreateGuestRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 16, depth)?;
self.2.encode(encoder, offset + 24, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for ControllerCreateGuestRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self {
name: fidl::new_empty!(
fidl::encoding::BoundedString<32>,
fidl::encoding::DefaultFuchsiaResourceDialect
),
network: fidl::new_empty!(
fidl::encoding::Endpoint<
fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
>,
fidl::encoding::DefaultFuchsiaResourceDialect
),
mac: fidl::new_empty!(
fidl::encoding::Boxed<fidl_fuchsia_net::MacAddress>,
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 ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
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 + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
fidl::encoding::BoundedString<32>,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.name,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
fidl::encoding::Endpoint<
fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.network,
decoder,
offset + 16,
_depth
)?;
fidl::decode!(
fidl::encoding::Boxed<fidl_fuchsia_net::MacAddress>,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.mac,
decoder,
offset + 24,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for ControllerCreateGuestResponse {
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 ControllerCreateGuestResponse {
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<
ControllerCreateGuestResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut ControllerCreateGuestResponse
{
#[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::<ControllerCreateGuestResponse>(offset);
fidl::encoding::Encode::<ControllerCreateGuestResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
(
<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.s),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<GuestMarker>>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<
ControllerCreateGuestResponse,
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::<ControllerCreateGuestResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for ControllerCreateGuestResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self {
s: fidl::new_empty!(
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<GuestMarker>>,
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<GuestMarker>>,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.s,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
}