blob: 03e201329548120866e8cdc2be5871e4f2544fb0 [file] [log] [blame]
// DO NOT EDIT: This file is machine-generated by fidlgen
#![warn(clippy::all)]
#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
pub mod natural {
#[derive(PartialEq, Clone, Debug)]
pub struct ExampleFooRequest {
pub s: ::std::string::String,
}
unsafe impl<___E> ::fidl_next::Encode<crate::wire::ExampleFooRequest<'static>, ___E>
for ExampleFooRequest
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
___E: ::fidl_next::Encoder,
{
#[inline]
fn encode(
self,
encoder_: &mut ___E,
out_: &mut ::core::mem::MaybeUninit<crate::wire::ExampleFooRequest<'static>>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let crate::wire::ExampleFooRequest {
s,
} = out_;
}
::fidl_next::Encode::encode(self.s, encoder_, s, 4294967295)?;
let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(s.as_mut_ptr()) };
::fidl_next::Constrained::validate(_field, 4294967295)?;
Ok(())
}
}
unsafe impl<'a, ___E> ::fidl_next::Encode<crate::wire::ExampleFooRequest<'static>, ___E>
for &'a ExampleFooRequest
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
___E: ::fidl_next::Encoder,
{
#[inline]
fn encode(
self,
encoder_: &mut ___E,
out_: &mut ::core::mem::MaybeUninit<crate::wire::ExampleFooRequest<'static>>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let crate::wire::ExampleFooRequest {
s,
} = out_;
}
::fidl_next::Encode::encode(&self.s, encoder_, s, 4294967295)?;
let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(s.as_mut_ptr()) };
::fidl_next::Constrained::validate(_field, 4294967295)?;
Ok(())
}
}
unsafe impl<___E>
::fidl_next::EncodeOption<
::fidl_next::WireBox<'static, crate::wire::ExampleFooRequest<'static>>,
___E,
> for ExampleFooRequest
where
___E: ::fidl_next::Encoder + ?Sized,
ExampleFooRequest: ::fidl_next::Encode<crate::wire::ExampleFooRequest<'static>, ___E>,
{
#[inline]
fn encode_option(
this: ::core::option::Option<Self>,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<
::fidl_next::WireBox<'static, crate::wire::ExampleFooRequest<'static>>,
>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner, ())?;
::fidl_next::WireBox::encode_present(out);
} else {
::fidl_next::WireBox::encode_absent(out);
}
Ok(())
}
}
unsafe impl<'a, ___E>
::fidl_next::EncodeOption<
::fidl_next::WireBox<'static, crate::wire::ExampleFooRequest<'static>>,
___E,
> for &'a ExampleFooRequest
where
___E: ::fidl_next::Encoder + ?Sized,
&'a ExampleFooRequest: ::fidl_next::Encode<crate::wire::ExampleFooRequest<'static>, ___E>,
{
#[inline]
fn encode_option(
this: ::core::option::Option<Self>,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<
::fidl_next::WireBox<'static, crate::wire::ExampleFooRequest<'static>>,
>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner, ())?;
::fidl_next::WireBox::encode_present(out);
} else {
::fidl_next::WireBox::encode_absent(out);
}
Ok(())
}
}
impl<'de> ::fidl_next::FromWire<crate::wire::ExampleFooRequest<'de>> for ExampleFooRequest {
#[inline]
fn from_wire(wire: crate::wire::ExampleFooRequest<'de>) -> Self {
Self { s: ::fidl_next::FromWire::from_wire(wire.s) }
}
}
impl<'de> ::fidl_next::FromWireRef<crate::wire::ExampleFooRequest<'de>> for ExampleFooRequest {
#[inline]
fn from_wire_ref(wire: &crate::wire::ExampleFooRequest<'de>) -> Self {
Self { s: ::fidl_next::FromWireRef::from_wire_ref(&wire.s) }
}
}
#[derive(PartialEq, Clone, Debug)]
#[repr(C)]
pub struct ExampleFooResponse {
pub y: i64,
}
unsafe impl<___E> ::fidl_next::Encode<crate::wire::ExampleFooResponse, ___E> for ExampleFooResponse
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
{
const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
Self,
crate::wire::ExampleFooResponse,
> = unsafe {
::fidl_next::CopyOptimization::enable_if(
true && <i64 as ::fidl_next::Encode<::fidl_next::WireI64, ___E>>::COPY_OPTIMIZATION
.is_enabled(),
)
};
#[inline]
fn encode(
self,
encoder_: &mut ___E,
out_: &mut ::core::mem::MaybeUninit<crate::wire::ExampleFooResponse>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let crate::wire::ExampleFooResponse {
y,
} = out_;
}
::fidl_next::Encode::encode(self.y, encoder_, y, ())?;
let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(y.as_mut_ptr()) };
Ok(())
}
}
unsafe impl<'a, ___E> ::fidl_next::Encode<crate::wire::ExampleFooResponse, ___E>
for &'a ExampleFooResponse
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
{
#[inline]
fn encode(
self,
encoder_: &mut ___E,
out_: &mut ::core::mem::MaybeUninit<crate::wire::ExampleFooResponse>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let crate::wire::ExampleFooResponse {
y,
} = out_;
}
::fidl_next::Encode::encode(&self.y, encoder_, y, ())?;
let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(y.as_mut_ptr()) };
Ok(())
}
}
unsafe impl<___E>
::fidl_next::EncodeOption<
::fidl_next::WireBox<'static, crate::wire::ExampleFooResponse>,
___E,
> for ExampleFooResponse
where
___E: ::fidl_next::Encoder + ?Sized,
ExampleFooResponse: ::fidl_next::Encode<crate::wire::ExampleFooResponse, ___E>,
{
#[inline]
fn encode_option(
this: ::core::option::Option<Self>,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<
::fidl_next::WireBox<'static, crate::wire::ExampleFooResponse>,
>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner, ())?;
::fidl_next::WireBox::encode_present(out);
} else {
::fidl_next::WireBox::encode_absent(out);
}
Ok(())
}
}
unsafe impl<'a, ___E>
::fidl_next::EncodeOption<
::fidl_next::WireBox<'static, crate::wire::ExampleFooResponse>,
___E,
> for &'a ExampleFooResponse
where
___E: ::fidl_next::Encoder + ?Sized,
&'a ExampleFooResponse: ::fidl_next::Encode<crate::wire::ExampleFooResponse, ___E>,
{
#[inline]
fn encode_option(
this: ::core::option::Option<Self>,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<
::fidl_next::WireBox<'static, crate::wire::ExampleFooResponse>,
>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner, ())?;
::fidl_next::WireBox::encode_present(out);
} else {
::fidl_next::WireBox::encode_absent(out);
}
Ok(())
}
}
impl ::fidl_next::FromWire<crate::wire::ExampleFooResponse> for ExampleFooResponse {
const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
crate::wire::ExampleFooResponse,
Self,
> = unsafe {
::fidl_next::CopyOptimization::enable_if(
true && <i64 as ::fidl_next::FromWire<::fidl_next::WireI64>>::COPY_OPTIMIZATION
.is_enabled(),
)
};
#[inline]
fn from_wire(wire: crate::wire::ExampleFooResponse) -> Self {
Self { y: ::fidl_next::FromWire::from_wire(wire.y) }
}
}
impl ::fidl_next::FromWireRef<crate::wire::ExampleFooResponse> for ExampleFooResponse {
#[inline]
fn from_wire_ref(wire: &crate::wire::ExampleFooResponse) -> Self {
Self { y: ::fidl_next::FromWireRef::from_wire_ref(&wire.y) }
}
}
}
pub mod wire {
/// The wire type corresponding to [`ExampleFooRequest`].
#[derive(Debug)]
#[repr(C)]
pub struct ExampleFooRequest<'de> {
pub s: ::fidl_next::WireString<'de>,
}
static_assertions::const_assert_eq!(std::mem::size_of::<ExampleFooRequest<'_>>(), 16);
static_assertions::const_assert_eq!(std::mem::align_of::<ExampleFooRequest<'_>>(), 8);
static_assertions::const_assert_eq!(std::mem::offset_of!(ExampleFooRequest<'_>, s), 0);
unsafe impl ::fidl_next::Wire for ExampleFooRequest<'static> {
type Decoded<'de> = ExampleFooRequest<'de>;
#[inline]
fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
::fidl_next::munge! {
let Self {
s,
} = &mut *out_;
}
::fidl_next::Wire::zero_padding(s);
}
}
unsafe impl<___D> ::fidl_next::Decode<___D> for ExampleFooRequest<'static>
where
___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
___D: ::fidl_next::Decoder,
{
fn decode(
slot_: ::fidl_next::Slot<'_, Self>,
decoder_: &mut ___D,
_: (),
) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge! {
let Self {
mut s,
} = slot_;
}
let _field = s.as_mut();
::fidl_next::Constrained::validate(_field, 4294967295)?;
::fidl_next::Decode::decode(s.as_mut(), decoder_, 4294967295)?;
Ok(())
}
}
impl<'de> ::fidl_next::IntoNatural for ExampleFooRequest<'de> {
type Natural = crate::natural::ExampleFooRequest;
}
impl ::fidl_next::Unconstrained for ExampleFooRequest<'static> {}
/// The wire type corresponding to [`ExampleFooResponse`].
#[derive(Clone, Debug)]
#[repr(C)]
pub struct ExampleFooResponse {
pub y: ::fidl_next::WireI64,
}
static_assertions::const_assert_eq!(std::mem::size_of::<ExampleFooResponse>(), 8);
static_assertions::const_assert_eq!(std::mem::align_of::<ExampleFooResponse>(), 8);
static_assertions::const_assert_eq!(std::mem::offset_of!(ExampleFooResponse, y), 0);
unsafe impl ::fidl_next::Wire for ExampleFooResponse {
type Decoded<'de> = ExampleFooResponse;
#[inline]
fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
::fidl_next::munge! {
let Self {
y,
} = &mut *out_;
}
::fidl_next::Wire::zero_padding(y);
}
}
unsafe impl<___D> ::fidl_next::Decode<___D> for ExampleFooResponse
where
___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
{
fn decode(
slot_: ::fidl_next::Slot<'_, Self>,
decoder_: &mut ___D,
_: (),
) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge! {
let Self {
mut y,
} = slot_;
}
let _field = y.as_mut();
::fidl_next::Decode::decode(y.as_mut(), decoder_, ())?;
Ok(())
}
}
impl ::fidl_next::IntoNatural for ExampleFooResponse {
type Natural = crate::natural::ExampleFooResponse;
}
impl ::fidl_next::Unconstrained for ExampleFooResponse {}
}
pub mod wire_optional {}
pub mod generic {
pub struct ExampleFooRequest<T0> {
pub s: T0,
}
unsafe impl<___E, T0> ::fidl_next::Encode<crate::wire::ExampleFooRequest<'static>, ___E>
for ExampleFooRequest<T0>
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
___E: ::fidl_next::Encoder,
T0: ::fidl_next::Encode<::fidl_next::WireString<'static>, ___E>,
{
#[inline]
fn encode(
self,
encoder_: &mut ___E,
out_: &mut ::core::mem::MaybeUninit<crate::wire::ExampleFooRequest<'static>>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let crate::wire::ExampleFooRequest {
s,
} = out_;
}
::fidl_next::Encode::encode(self.s, encoder_, s, 4294967295)?;
Ok(())
}
}
pub struct ExampleFooResponse<T0> {
pub y: T0,
}
unsafe impl<___E, T0> ::fidl_next::Encode<crate::wire::ExampleFooResponse, ___E>
for ExampleFooResponse<T0>
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
T0: ::fidl_next::Encode<::fidl_next::WireI64, ___E>,
{
#[inline]
fn encode(
self,
encoder_: &mut ___E,
out_: &mut ::core::mem::MaybeUninit<crate::wire::ExampleFooResponse>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let crate::wire::ExampleFooResponse {
y,
} = out_;
}
::fidl_next::Encode::encode(self.y, encoder_, y, ())?;
Ok(())
}
}
}
pub use self::natural::*;
/// The type corresponding to the Example protocol.
#[derive(PartialEq, Debug)]
pub struct Example;
#[cfg(target_os = "fuchsia")]
impl ::fidl_next::HasTransport for Example {
type Transport = ::fidl_next::fuchsia::zx::Channel;
}
pub mod example {
pub mod prelude {
pub use crate::{Example, ExampleClientHandler, ExampleServerHandler, example};
pub use crate::natural::ExampleFooRequest;
pub use crate::natural::ExampleFooResponse;
}
pub struct Foo;
impl ::fidl_next::Method for Foo {
const ORDINAL: u64 = 1107623248440401476;
const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
::fidl_next::protocol::Flexibility::Strict;
type Protocol = crate::Example;
type Request = crate::wire::ExampleFooRequest<'static>;
type Response =
::fidl_next::WireResult<'static, crate::wire::ExampleFooResponse, ::fidl_next::WireU32>;
}
impl<___R> ::fidl_next::Respond<___R> for Foo {
type Output = ::core::result::Result<
crate::generic::ExampleFooResponse<___R>,
::fidl_next::util::Never,
>;
fn respond(response: ___R) -> Self::Output {
::core::result::Result::Ok(crate::generic::ExampleFooResponse { y: response })
}
}
impl<___R> ::fidl_next::RespondErr<___R> for Foo {
type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
fn respond_err(response: ___R) -> Self::Output {
::core::result::Result::Err(response)
}
}
mod ___detail {
unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Example
where
___T: ::fidl_next::Transport,
{
type Client = ExampleClient<___T>;
type Server = ExampleServer<___T>;
}
/// The client for the `Example` protocol.
#[repr(transparent)]
pub struct ExampleClient<___T: ::fidl_next::Transport> {
#[allow(dead_code)]
client: ::fidl_next::protocol::Client<___T>,
}
impl<___T> ExampleClient<___T>
where
___T: ::fidl_next::Transport,
{
pub fn foo(
&self,
s: impl ::fidl_next::Encode<
::fidl_next::WireString<'static>,
<___T as ::fidl_next::Transport>::SendBuffer,
>,
) -> ::fidl_next::TwoWayFuture<'_, super::Foo, ___T>
where
<___T as ::fidl_next::Transport>::SendBuffer:
::fidl_next::encoder::InternalHandleEncoder,
<___T as ::fidl_next::Transport>::SendBuffer: ::fidl_next::Encoder,
{
self.foo_with(crate::generic::ExampleFooRequest { s })
}
pub fn foo_with<___R>(
&self,
request: ___R,
) -> ::fidl_next::TwoWayFuture<'_, super::Foo, ___T>
where
___R: ::fidl_next::Encode<
crate::wire::ExampleFooRequest<'static>,
<___T as ::fidl_next::Transport>::SendBuffer,
>,
{
::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
1107623248440401476,
<super::Foo as ::fidl_next::Method>::FLEXIBILITY,
request,
))
}
}
/// The server for the `Example` protocol.
#[repr(transparent)]
pub struct ExampleServer<___T: ::fidl_next::Transport> {
server: ::fidl_next::protocol::Server<___T>,
}
impl<___T> ExampleServer<___T> where ___T: ::fidl_next::Transport {}
}
}
/// A client handler for the Example protocol.
///
/// See [`Example`] for more details.
pub trait ExampleClientHandler<
#[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
#[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
>
{
}
impl<___T> ExampleClientHandler<___T> for ::fidl_next::IgnoreEvents where
___T: ::fidl_next::Transport
{
}
impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Example
where
___H: ExampleClientHandler<___T> + ::core::marker::Send,
___T: ::fidl_next::Transport,
<example::Foo as ::fidl_next::Method>::Response:
::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
{
async fn on_event(
handler: &mut ___H,
ordinal: u64,
flexibility: ::fidl_next::protocol::Flexibility,
buffer: ___T::RecvBuffer,
) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
match ordinal {
ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
}
}
}
/// A server handler for the Example protocol.
///
/// See [`Example`] for more details.
pub trait ExampleServerHandler<
#[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
#[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
>
{
fn foo(
&mut self,
request: ::fidl_next::Request<example::Foo, ___T>,
responder: ::fidl_next::Responder<example::Foo, ___T>,
) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
}
impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Example
where
___H: ExampleServerHandler<___T> + ::core::marker::Send,
___T: ::fidl_next::Transport,
<example::Foo as ::fidl_next::Method>::Request:
::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
{
async fn on_one_way(
handler: &mut ___H,
ordinal: u64,
flexibility: ::fidl_next::protocol::Flexibility,
buffer: ___T::RecvBuffer,
) -> ::core::result::Result<
(),
::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
> {
match ordinal {
ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
}
}
async fn on_two_way(
handler: &mut ___H,
ordinal: u64,
flexibility: ::fidl_next::protocol::Flexibility,
buffer: ___T::RecvBuffer,
responder: ::fidl_next::protocol::Responder<___T>,
) -> ::core::result::Result<
(),
::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
> {
match ordinal {
1107623248440401476 => {
let responder = ::fidl_next::Responder::from_untyped(responder);
match ::fidl_next::DecoderExt::decode(buffer) {
Ok(decoded) => {
handler.foo(decoded, responder).await;
Ok(())
}
Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
ordinal: 1107623248440401476,
error,
}),
}
}
ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
}
}
}
/// Compatibility shims which mimic some API surfaces of the current Rust bindings.
pub mod compat {
impl ::fidl_next::CompatFrom<crate::ExampleFooRequest> for ::fidl_test_error::ExampleFooRequest {
#[inline]
fn compat_from(value: crate::ExampleFooRequest) -> Self {
Self { s: ::fidl_next::CompatFrom::compat_from(value.s) }
}
}
impl ::fidl_next::CompatFrom<::fidl_test_error::ExampleFooRequest> for crate::ExampleFooRequest {
#[inline]
fn compat_from(value: ::fidl_test_error::ExampleFooRequest) -> Self {
Self { s: ::fidl_next::CompatFrom::compat_from(value.s) }
}
}
impl ::fidl_next::CompatFrom<crate::ExampleFooResponse> for ::fidl_test_error::ExampleFooResponse {
#[inline]
fn compat_from(value: crate::ExampleFooResponse) -> Self {
Self { y: ::fidl_next::CompatFrom::compat_from(value.y) }
}
}
impl ::fidl_next::CompatFrom<::fidl_test_error::ExampleFooResponse> for crate::ExampleFooResponse {
#[inline]
fn compat_from(value: ::fidl_test_error::ExampleFooResponse) -> Self {
Self { y: ::fidl_next::CompatFrom::compat_from(value.y) }
}
}
#[cfg(target_os = "fuchsia")]
/// An alias for a client over `zx::Channel` for the `Example`
/// protocol.
pub type ExampleProxy = ::fidl_next::Client<crate::Example>;
impl ::fidl_next::CompatFrom<crate::Example> for ::fidl_test_error::ExampleMarker {
fn compat_from(_: crate::Example) -> Self {
Self
}
}
impl ::fidl_next::CompatFrom<::fidl_test_error::ExampleMarker> for crate::Example {
fn compat_from(_: ::fidl_test_error::ExampleMarker) -> Self {
Self
}
}
#[cfg(target_os = "fuchsia")]
impl ::fidl_next::ClientCompatFrom<::fidl_test_error::ExampleProxy> for crate::Example {
fn client_compat_from(
proxy: ::fidl_test_error::ExampleProxy,
) -> ::fidl_next::ClientDispatcher<Self, ::fidl_next::fuchsia::zx::Channel> {
let channel = ::fidl::endpoints::Proxy::into_channel(proxy).unwrap().into_zx_channel();
let client_end = ::fidl_next::ClientEnd::from_untyped(channel);
::fidl_next::ClientDispatcher::new(client_end)
}
}
}