blob: bcf71285b5436ec6f48ef36bc6ee3f113f761908 [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 {
pub use fidl_next_common_test_versions::natural::*;
#[derive(PartialEq, Debug)]
#[repr(C)]
pub struct Struct {
pub x: u32,
}
unsafe impl<___E> ::fidl_next::Encode<crate::wire::Struct, ___E> for Struct
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
___E: ::fidl_next::fuchsia::HandleEncoder,
{
const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, crate::wire::Struct> = unsafe {
::fidl_next::CopyOptimization::enable_if(
true && <u32 as ::fidl_next::Encode<::fidl_next::WireU32, ___E>>::COPY_OPTIMIZATION
.is_enabled(),
)
};
#[inline]
fn encode(
self,
encoder_: &mut ___E,
out_: &mut ::core::mem::MaybeUninit<crate::wire::Struct>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let crate::wire::Struct {
x,
} = out_;
}
::fidl_next::Encode::encode(self.x, encoder_, x, ())?;
let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(x.as_mut_ptr()) };
Ok(())
}
}
unsafe impl<___E>
::fidl_next::EncodeOption<::fidl_next::WireBox<'static, crate::wire::Struct>, ___E>
for Struct
where
___E: ::fidl_next::Encoder + ?Sized,
Struct: ::fidl_next::Encode<crate::wire::Struct, ___E>,
{
#[inline]
fn encode_option(
this: ::core::option::Option<Self>,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<::fidl_next::WireBox<'static, crate::wire::Struct>>,
_: (),
) -> ::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::Struct> for Struct {
const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<crate::wire::Struct, Self> = unsafe {
::fidl_next::CopyOptimization::enable_if(
true && <u32 as ::fidl_next::FromWire<::fidl_next::WireU32>>::COPY_OPTIMIZATION
.is_enabled(),
)
};
#[inline]
fn from_wire(wire: crate::wire::Struct) -> Self {
Self { x: ::fidl_next::FromWire::from_wire(wire.x) }
}
}
#[derive(PartialEq, Debug, Default)]
pub struct Table {
pub x: ::core::option::Option<u32>,
}
impl Table {
fn __max_ordinal(&self) -> usize {
if self.x.is_some() {
return 1;
}
0
}
}
unsafe impl<___E> ::fidl_next::Encode<crate::wire::Table<'static>, ___E> for Table
where
___E: ::fidl_next::Encoder + ?Sized,
___E: ::fidl_next::fuchsia::HandleEncoder,
{
#[inline]
fn encode(
mut self,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<crate::wire::Table<'static>>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let crate::wire::Table { table } = out);
let max_ord = self.__max_ordinal();
let mut out = ::core::mem::MaybeUninit::<::fidl_next::WireEnvelope>::uninit();
::fidl_next::Wire::zero_padding(&mut out);
let mut preallocated =
::fidl_next::EncoderExt::preallocate::<::fidl_next::WireEnvelope>(encoder, max_ord);
for i in 1..=max_ord {
match i {
1 => {
if let Some(value) = self.x.take() {
::fidl_next::WireEnvelope::encode_value::<::fidl_next::WireU32, ___E>(
value,
preallocated.encoder,
&mut out,
(),
)?;
} else {
::fidl_next::WireEnvelope::encode_zero(&mut out)
}
}
_ => ::fidl_next::WireEnvelope::encode_zero(&mut out),
}
unsafe {
preallocated.write_next(out.assume_init_ref());
}
}
::fidl_next::WireTable::encode_len(table, max_ord);
Ok(())
}
}
impl<'de> ::fidl_next::FromWire<crate::wire::Table<'de>> for Table {
#[inline]
fn from_wire(wire_: crate::wire::Table<'de>) -> Self {
let wire_ = ::core::mem::ManuallyDrop::new(wire_);
let x = wire_.table.get(1);
Self {
x: x.map(|envelope| {
::fidl_next::FromWire::from_wire(unsafe {
envelope.read_unchecked::<::fidl_next::WireU32>()
})
}),
}
}
}
#[derive(PartialEq, Debug)]
pub enum Union {
X(u32),
UnknownOrdinal_(u64),
}
impl Union {
pub fn is_unknown(&self) -> bool {
#[allow(unreachable_patterns)]
match self {
Self::UnknownOrdinal_(_) => true,
_ => false,
}
}
}
unsafe impl<___E> ::fidl_next::Encode<crate::wire::Union<'static>, ___E> for Union
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
___E: ::fidl_next::Encoder,
___E: ::fidl_next::fuchsia::HandleEncoder,
{
#[inline]
fn encode(
self,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<crate::wire::Union<'static>>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let crate::wire::Union { raw, _phantom: _ } = out);
match self {
Self::X(value) => {
::fidl_next::RawWireUnion::encode_as::<___E, ::fidl_next::WireU32>(
value,
1,
encoder,
raw,
(),
)?
}
Self::UnknownOrdinal_(ordinal) => {
return Err(::fidl_next::EncodeError::UnknownUnionOrdinal(ordinal as usize));
}
}
Ok(())
}
}
unsafe impl<___E> ::fidl_next::EncodeOption<crate::wire_optional::Union<'static>, ___E> for Union
where
___E: ?Sized,
Union: ::fidl_next::Encode<crate::wire::Union<'static>, ___E>,
{
#[inline]
fn encode_option(
this: ::core::option::Option<Self>,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<crate::wire_optional::Union<'static>>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let crate::wire_optional::Union { raw, _phantom: _ } = &mut *out);
if let Some(inner) = this {
let value_out = unsafe { &mut *out.as_mut_ptr().cast() };
::fidl_next::Encode::encode(inner, encoder, value_out, ())?;
} else {
::fidl_next::RawWireUnion::encode_absent(raw);
}
Ok(())
}
}
impl<'de> ::fidl_next::FromWire<crate::wire::Union<'de>> for Union {
#[inline]
fn from_wire(wire: crate::wire::Union<'de>) -> Self {
let wire = ::core::mem::ManuallyDrop::new(wire);
match wire.raw.ordinal() {
1 => Self::X(::fidl_next::FromWire::from_wire(unsafe {
wire.raw.get().read_unchecked::<::fidl_next::WireU32>()
})),
ord => return Self::UnknownOrdinal_(ord as u64),
}
}
}
impl<'de> ::fidl_next::FromWireOption<crate::wire_optional::Union<'de>> for Union {
#[inline]
fn from_wire_option(
wire: crate::wire_optional::Union<'de>,
) -> ::core::option::Option<Self> {
if let Some(inner) = wire.into_option() {
Some(::fidl_next::FromWire::from_wire(inner))
} else {
None
}
}
}
impl<'de> ::fidl_next::FromWireOption<crate::wire_optional::Union<'de>> for Box<Union> {
#[inline]
fn from_wire_option(
wire: crate::wire_optional::Union<'de>,
) -> ::core::option::Option<Self> {
<
Union as ::fidl_next::FromWireOption<crate::wire_optional::Union<'de>>
>::from_wire_option(wire).map(Box::new)
}
}
}
pub mod wire {
pub use fidl_next_common_test_versions::wire::*;
/// The wire type corresponding to [`Struct`].
#[derive(Debug)]
#[repr(C)]
pub struct Struct {
pub x: ::fidl_next::WireU32,
}
static_assertions::const_assert_eq!(std::mem::size_of::<Struct>(), 4);
static_assertions::const_assert_eq!(std::mem::align_of::<Struct>(), 4);
static_assertions::const_assert_eq!(std::mem::offset_of!(Struct, x), 0);
unsafe impl ::fidl_next::Wire for Struct {
type Owned<'de> = Struct;
#[inline]
fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
::fidl_next::munge! {
let Self {
x,
} = &mut *out_;
}
::fidl_next::Wire::zero_padding(x);
}
}
unsafe impl<___D> ::fidl_next::Decode<___D> for Struct
where
___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
___D: ::fidl_next::fuchsia::HandleDecoder,
{
fn decode(
slot_: ::fidl_next::Slot<'_, Self>,
decoder_: &mut ___D,
_: (),
) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge! {
let Self {
mut x,
} = slot_;
}
let _field = x.as_mut();
::fidl_next::Decode::decode(x.as_mut(), decoder_, ())?;
Ok(())
}
}
impl ::fidl_next::IntoNatural for Struct {
type Natural = crate::natural::Struct;
}
impl ::fidl_next::Unconstrained for Struct {}
/// The wire type corresponding to [`Table`].
#[repr(C)]
pub struct Table<'de> {
pub(crate) table: ::fidl_next::WireTable<'de>,
}
impl<'de> Drop for Table<'de> {
fn drop(&mut self) {
let _ = self
.table
.get(1)
.map(|envelope| unsafe { envelope.read_unchecked::<::fidl_next::WireU32>() });
}
}
unsafe impl ::fidl_next::Wire for Table<'static> {
type Owned<'de> = Table<'de>;
#[inline]
fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
::fidl_next::munge!(let Self { table } = out);
::fidl_next::WireTable::zero_padding(table);
}
}
unsafe impl<___D> ::fidl_next::Decode<___D> for Table<'static>
where
___D: ::fidl_next::Decoder + ?Sized,
___D: ::fidl_next::fuchsia::HandleDecoder,
{
fn decode(
slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
_: (),
) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge!(let Self { table } = slot);
::fidl_next::WireTable::decode_with(table, decoder, |ordinal, mut slot, decoder| {
match ordinal {
0 => unsafe { ::core::hint::unreachable_unchecked() },
1 => {
::fidl_next::WireEnvelope::decode_as::<___D, ::fidl_next::WireU32>(
slot.as_mut(),
decoder,
(),
)?;
Ok(())
}
_ => ::fidl_next::WireEnvelope::decode_unknown(slot, decoder),
}
})
}
}
impl<'de> Table<'de> {
pub fn x(&self) -> ::core::option::Option<&::fidl_next::WireU32> {
unsafe { Some(self.table.get(1)?.deref_unchecked()) }
}
}
impl<'de> ::core::fmt::Debug for Table<'de> {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::result::Result<(), ::core::fmt::Error> {
f.debug_struct("Table").field("x", &self.x()).finish()
}
}
impl<'de> ::fidl_next::IntoNatural for Table<'de> {
type Natural = crate::natural::Table;
}
impl ::fidl_next::Unconstrained for Table<'_> {}
/// The wire type corresponding to [`Union`].
#[repr(transparent)]
pub struct Union<'de> {
pub(crate) raw: ::fidl_next::RawWireUnion,
pub(crate) _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
}
impl<'de> Drop for Union<'de> {
fn drop(&mut self) {
match self.raw.ordinal() {
1 => {
let _ = unsafe { self.raw.get().read_unchecked::<::fidl_next::WireU32>() };
}
_ => (),
}
}
}
unsafe impl ::fidl_next::Wire for Union<'static> {
type Owned<'de> = Union<'de>;
#[inline]
fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
::fidl_next::RawWireUnion::zero_padding(raw);
}
}
pub mod union {
pub enum Ref<'de> {
X(&'de ::fidl_next::WireU32),
UnknownOrdinal_(u64),
}
}
impl<'de> Union<'de> {
pub fn as_ref(&self) -> crate::wire::union::Ref<'_> {
match self.raw.ordinal() {
1 => crate::wire::union::Ref::X(unsafe {
self.raw.get().deref_unchecked::<::fidl_next::WireU32>()
}),
unknown => crate::wire::union::Ref::UnknownOrdinal_(unknown),
}
}
}
unsafe impl<___D> ::fidl_next::Decode<___D> for Union<'static>
where
___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
___D: ::fidl_next::Decoder,
___D: ::fidl_next::fuchsia::HandleDecoder,
{
fn decode(
mut slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
_: (),
) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
1 => ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireU32>(
raw,
decoder,
(),
)?,
_ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
}
Ok(())
}
}
impl<'de> ::core::fmt::Debug for Union<'de> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
match self.raw.ordinal() {
1 => unsafe { self.raw.get().deref_unchecked::<::fidl_next::WireU32>().fmt(f) },
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
impl<'de> ::fidl_next::IntoNatural for Union<'de> {
type Natural = crate::natural::Union;
}
impl ::fidl_next::Unconstrained for Union<'static> {}
}
pub mod wire_optional {
pub use fidl_next_common_test_versions::wire_optional::*;
#[repr(transparent)]
pub struct Union<'de> {
pub(crate) raw: ::fidl_next::RawWireUnion,
pub(crate) _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
}
unsafe impl ::fidl_next::Wire for Union<'static> {
type Owned<'de> = Union<'de>;
#[inline]
fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
::fidl_next::RawWireUnion::zero_padding(raw);
}
}
impl<'de> Union<'de> {
pub fn is_some(&self) -> bool {
self.raw.is_some()
}
pub fn is_none(&self) -> bool {
self.raw.is_none()
}
pub fn as_ref(&self) -> ::core::option::Option<&crate::wire::Union<'de>> {
if self.is_some() { Some(unsafe { &*(self as *const Self).cast() }) } else { None }
}
pub fn into_option(self) -> ::core::option::Option<crate::wire::Union<'de>> {
if self.is_some() {
Some(crate::wire::Union { raw: self.raw, _phantom: ::core::marker::PhantomData })
} else {
None
}
}
}
unsafe impl<___D> ::fidl_next::Decode<___D> for Union<'static>
where
___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
___D: ::fidl_next::Decoder,
___D: ::fidl_next::fuchsia::HandleDecoder,
{
fn decode(
mut slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
_: (),
) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
1 => ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireU32>(
raw,
decoder,
(),
)?,
0 => ::fidl_next::RawWireUnion::decode_absent(raw)?,
_ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
}
Ok(())
}
}
impl<'de> ::core::fmt::Debug for Union<'de> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
self.as_ref().fmt(f)
}
}
impl<'de> ::fidl_next::IntoNatural for Union<'de> {
type Natural = ::core::option::Option<crate::natural::Union>;
}
impl ::fidl_next::Unconstrained for Union<'static> {}
}
pub mod generic {
pub use fidl_next_common_test_versions::generic::*;
pub struct Struct<T0> {
pub x: T0,
}
unsafe impl<___E, T0> ::fidl_next::Encode<crate::wire::Struct, ___E> for Struct<T0>
where
___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
___E: ::fidl_next::fuchsia::HandleEncoder,
T0: ::fidl_next::Encode<::fidl_next::WireU32, ___E>,
{
#[inline]
fn encode(
self,
encoder_: &mut ___E,
out_: &mut ::core::mem::MaybeUninit<crate::wire::Struct>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let crate::wire::Struct {
x,
} = out_;
}
::fidl_next::Encode::encode(self.x, encoder_, x, ())?;
Ok(())
}
}
}
pub use self::natural::*;
/// The type corresponding to the Service service.
#[derive(Debug)]
pub struct Service;
impl ::fidl_next::DiscoverableService for Service {
const SERVICE_NAME: &'static str = "test.versions.Service";
const MEMBER_NAMES: &'static [&'static str] = &["p"];
}
impl ::fidl_next::HasServiceRequest<::fidl_next::fuchsia::zx::Channel> for Service {}
impl<___C> ::fidl_next::Service<___C> for Service
where
___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
{
type Connector = ServiceConnector<___C>;
}
/// A strongly-typed service connector for the `Service` service.
#[repr(transparent)]
pub struct ServiceConnector<___C> {
#[allow(dead_code)]
connector: ___C,
}
impl<___C> ServiceConnector<___C>
where
___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
{
/// Attempts to connect to the `p` service member.
pub fn p(
&self,
server_end: ::fidl_next::ServerEnd<crate::Protocol, ::fidl_next::fuchsia::zx::Channel>,
) -> ::core::result::Result<
(),
<___C as ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>>::Error,
> {
::fidl_next::protocol::ServiceConnector::<
::fidl_next::fuchsia::zx::Channel
>::connect_to_member(
&self.connector,
"p",
server_end.into_untyped(),
)
}
}
/// A service handler for the `Service` service.
pub trait ServiceHandler {
/// Handles an attempt to connect to the `p` member.
fn p(
&self,
server_end: ::fidl_next::ServerEnd<crate::Protocol, ::fidl_next::fuchsia::zx::Channel>,
);
}
impl<___H, ___T> ::fidl_next::DispatchServiceHandler<___H, ___T> for Service
where
___H: ServiceHandler,
::fidl_next::fuchsia::zx::Channel: ::fidl_next::InstanceFromServiceTransport<___T>,
{
fn on_connection(handler: &___H, member: &str, server_end: ___T) {
use ::fidl_next::InstanceFromServiceTransport;
match member {
"p" => handler.p(::fidl_next::ServerEnd::from_untyped(
::fidl_next::fuchsia::zx::Channel::from_service_transport(server_end),
)),
_ => unreachable!(),
}
}
}
pub use fidl_next_common_test_versions::*;
/// Compatibility shims which mimic some API surfaces of the current Rust bindings.
pub mod compat {
pub use fidl_next_common_test_versions::compat::*;
impl ::fidl_next::CompatFrom<crate::Struct> for ::fidl_test_versions::Struct {
#[inline]
fn compat_from(value: crate::Struct) -> Self {
Self { x: ::fidl_next::CompatFrom::compat_from(value.x) }
}
}
impl ::fidl_next::CompatFrom<::fidl_test_versions::Struct> for crate::Struct {
#[inline]
fn compat_from(value: ::fidl_test_versions::Struct) -> Self {
Self { x: ::fidl_next::CompatFrom::compat_from(value.x) }
}
}
impl ::fidl_next::CompatFrom<crate::Table> for ::fidl_test_versions::Table {
fn compat_from(value: crate::Table) -> Self {
Self {
x: ::fidl_next::CompatFrom::compat_from(value.x),
__source_breaking: ::fidl::marker::SourceBreaking,
}
}
}
impl ::fidl_next::CompatFrom<::fidl_test_versions::Table> for crate::Table {
fn compat_from(value: ::fidl_test_versions::Table) -> Self {
Self { x: ::fidl_next::CompatFrom::compat_from(value.x) }
}
}
impl ::fidl_next::CompatFrom<crate::Union> for ::fidl_test_versions::Union {
fn compat_from(value: crate::Union) -> Self {
match value {
crate::Union::X(value) => Self::X(::fidl_next::CompatFrom::compat_from(value)),
crate::Union::UnknownOrdinal_(unknown_ordinal) => {
Self::__SourceBreaking { unknown_ordinal }
}
}
}
}
impl ::fidl_next::CompatFrom<::fidl_test_versions::Union> for crate::Union {
fn compat_from(value: ::fidl_test_versions::Union) -> Self {
match value {
::fidl_test_versions::Union::X(value) => {
Self::X(::fidl_next::CompatFrom::compat_from(value))
}
::fidl_test_versions::Union::__SourceBreaking { unknown_ordinal } => {
Self::UnknownOrdinal_(unknown_ordinal)
}
}
}
}
}