| // 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 type Alias = ::std::string::String; |
| |
| ::fidl_next::bitflags::bitflags! { |
| #[derive( |
| Clone, |
| Copy, |
| Debug, |
| PartialEq, |
| Eq, |
| Hash, |
| )] |
| pub struct Bits: u32 { |
| const A = 1; |
| const _ = !0; |
| } |
| } |
| |
| unsafe impl<___E> ::fidl_next::Encode<crate::wire::Bits, ___E> for Bits |
| where |
| ___E: ?Sized, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<crate::wire::Bits>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::Encode::encode(&self, encoder, out, ()) |
| } |
| } |
| |
| unsafe impl<'a, ___E> ::fidl_next::Encode<crate::wire::Bits, ___E> for &'a Bits |
| where |
| ___E: ?Sized, |
| { |
| #[inline] |
| fn encode( |
| self, |
| _: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<crate::wire::Bits>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge!(let crate::wire::Bits { value } = out); |
| |
| let _ = value.write(::fidl_next::WireU32::from(self.bits())); |
| Ok(()) |
| } |
| } |
| |
| impl ::core::convert::From<crate::wire::Bits> for Bits { |
| fn from(wire: crate::wire::Bits) -> Self { |
| Self::from_bits_retain(u32::from(wire.value)) |
| } |
| } |
| |
| impl ::fidl_next::FromWire<crate::wire::Bits> for Bits { |
| #[inline] |
| fn from_wire(wire: crate::wire::Bits) -> Self { |
| Self::from(wire) |
| } |
| } |
| |
| impl ::fidl_next::FromWireRef<crate::wire::Bits> for Bits { |
| #[inline] |
| fn from_wire_ref(wire: &crate::wire::Bits) -> Self { |
| Self::from(*wire) |
| } |
| } |
| |
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
| #[repr(u32)] |
| pub enum Enum { |
| A = 1, |
| UnknownOrdinal_(u32) = 2, |
| } |
| impl ::std::convert::From<u32> for Enum { |
| fn from(value: u32) -> Self { |
| match value { |
| 1 => Self::A, |
| |
| _ => Self::UnknownOrdinal_(value), |
| } |
| } |
| } |
| |
| unsafe impl<___E> ::fidl_next::Encode<crate::wire::Enum, ___E> for Enum |
| where |
| ___E: ?Sized, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<crate::wire::Enum>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::Encode::encode(&self, encoder, out, ()) |
| } |
| } |
| |
| unsafe impl<'a, ___E> ::fidl_next::Encode<crate::wire::Enum, ___E> for &'a Enum |
| where |
| ___E: ?Sized, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<crate::wire::Enum>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge!(let crate::wire::Enum { value } = out); |
| let _ = value.write(::fidl_next::WireU32::from(match *self { |
| Enum::A => 1, |
| |
| Enum::UnknownOrdinal_(value) => value, |
| })); |
| |
| Ok(()) |
| } |
| } |
| |
| impl ::core::convert::From<crate::wire::Enum> for Enum { |
| fn from(wire: crate::wire::Enum) -> Self { |
| match u32::from(wire.value) { |
| 1 => Self::A, |
| |
| value => Self::UnknownOrdinal_(value), |
| } |
| } |
| } |
| |
| impl ::fidl_next::FromWire<crate::wire::Enum> for Enum { |
| #[inline] |
| fn from_wire(wire: crate::wire::Enum) -> Self { |
| Self::from(wire) |
| } |
| } |
| |
| impl ::fidl_next::FromWireRef<crate::wire::Enum> for Enum { |
| #[inline] |
| fn from_wire_ref(wire: &crate::wire::Enum) -> Self { |
| Self::from(*wire) |
| } |
| } |
| } |
| |
| pub mod wire { |
| |
| /// The wire type corresponding to [`Alias`](crate::natural::Alias). |
| pub type Alias<'de> = ::fidl_next::WireString<'de>; |
| |
| /// The wire type corresponding to [`Bits`](crate::natural::Bits). |
| #[derive(Clone, Copy, Debug)] |
| #[repr(transparent)] |
| pub struct Bits { |
| pub(crate) value: ::fidl_next::WireU32, |
| } |
| |
| unsafe impl ::fidl_next::Wire for Bits { |
| type Owned<'de> = Self; |
| |
| #[inline] |
| fn zero_padding(_: &mut ::core::mem::MaybeUninit<Self>) { |
| // Wire bits have no padding |
| } |
| } |
| |
| unsafe impl<___D> ::fidl_next::Decode<___D> for Bits |
| where |
| ___D: ?Sized, |
| { |
| fn decode( |
| slot: ::fidl_next::Slot<'_, Self>, |
| _: &mut ___D, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::DecodeError> { |
| Ok(()) |
| } |
| } |
| |
| impl ::core::convert::From<crate::natural::Bits> for Bits { |
| fn from(natural: crate::natural::Bits) -> Self { |
| Self { value: ::fidl_next::WireU32::from(natural.bits()) } |
| } |
| } |
| |
| impl ::fidl_next::IntoNatural for Bits { |
| type Natural = crate::natural::Bits; |
| } |
| |
| impl ::fidl_next::Unconstrained for Bits {} |
| |
| /// The wire type corresponding to [`Enum`]. |
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
| #[repr(transparent)] |
| pub struct Enum { |
| pub(crate) value: ::fidl_next::WireU32, |
| } |
| |
| unsafe impl ::fidl_next::Wire for Enum { |
| type Owned<'de> = Self; |
| |
| #[inline] |
| fn zero_padding(_: &mut ::core::mem::MaybeUninit<Self>) { |
| // Wire enums have no padding |
| } |
| } |
| |
| impl Enum { |
| pub const A: Enum = Enum { value: ::fidl_next::WireU32(1) }; |
| } |
| |
| unsafe impl<___D> ::fidl_next::Decode<___D> for Enum |
| where |
| ___D: ?Sized, |
| { |
| fn decode( |
| slot: ::fidl_next::Slot<'_, Self>, |
| _: &mut ___D, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::DecodeError> { |
| Ok(()) |
| } |
| } |
| |
| impl ::core::convert::From<crate::natural::Enum> for Enum { |
| fn from(natural: crate::natural::Enum) -> Self { |
| match natural { |
| crate::natural::Enum::A => Enum::A, |
| |
| crate::natural::Enum::UnknownOrdinal_(value) => { |
| Enum { value: ::fidl_next::WireU32::from(value) } |
| } |
| } |
| } |
| } |
| |
| impl ::fidl_next::IntoNatural for Enum { |
| type Natural = crate::natural::Enum; |
| } |
| |
| impl ::fidl_next::Unconstrained for Enum {} |
| } |
| |
| pub mod wire_optional {} |
| |
| pub mod generic {} |
| |
| pub use self::natural::*; |
| |
| pub const ADDED_AT_HEAD: bool = true as bool; |
| |
| pub const ADDED_AT_NEXT: bool = true as bool; |
| |
| pub const CONST: u32 = 0 as u32; |
| |
| /// The type corresponding to the OtherProtocol protocol. |
| #[derive(PartialEq, Debug)] |
| pub struct OtherProtocol; |
| |
| #[cfg(target_os = "fuchsia")] |
| impl ::fidl_next::HasTransport for OtherProtocol { |
| type Transport = ::fidl_next::fuchsia::zx::Channel; |
| } |
| |
| pub mod other_protocol { |
| pub mod prelude { |
| pub use crate::{ |
| OtherProtocol, OtherProtocolClientHandler, OtherProtocolServerHandler, other_protocol, |
| }; |
| } |
| |
| mod ___detail { |
| unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::OtherProtocol |
| where |
| ___T: ::fidl_next::Transport, |
| { |
| type Client = OtherProtocolClient<___T>; |
| type Server = OtherProtocolServer<___T>; |
| } |
| |
| /// The client for the `OtherProtocol` protocol. |
| #[repr(transparent)] |
| pub struct OtherProtocolClient<___T: ::fidl_next::Transport> { |
| #[allow(dead_code)] |
| client: ::fidl_next::protocol::Client<___T>, |
| } |
| |
| impl<___T> OtherProtocolClient<___T> where ___T: ::fidl_next::Transport {} |
| |
| /// The server for the `OtherProtocol` protocol. |
| #[repr(transparent)] |
| pub struct OtherProtocolServer<___T: ::fidl_next::Transport> { |
| server: ::fidl_next::protocol::Server<___T>, |
| } |
| |
| impl<___T> OtherProtocolServer<___T> where ___T: ::fidl_next::Transport {} |
| } |
| } |
| |
| /// A client handler for the OtherProtocol protocol. |
| /// |
| /// See [`OtherProtocol`] for more details. |
| pub trait OtherProtocolClientHandler< |
| #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel, |
| #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport, |
| > |
| { |
| } |
| |
| impl<___T> OtherProtocolClientHandler<___T> for ::fidl_next::IgnoreEvents where |
| ___T: ::fidl_next::Transport |
| { |
| } |
| |
| impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for OtherProtocol |
| where |
| ___H: OtherProtocolClientHandler<___T> + ::core::marker::Send, |
| ___T: ::fidl_next::Transport, |
| { |
| 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 OtherProtocol protocol. |
| /// |
| /// See [`OtherProtocol`] for more details. |
| pub trait OtherProtocolServerHandler< |
| #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel, |
| #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport, |
| > |
| { |
| } |
| |
| impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for OtherProtocol |
| where |
| ___H: OtherProtocolServerHandler<___T> + ::core::marker::Send, |
| ___T: ::fidl_next::Transport, |
| { |
| 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 { |
| ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)), |
| } |
| } |
| } |
| |
| /// The type corresponding to the Protocol protocol. |
| #[derive(PartialEq, Debug)] |
| pub struct Protocol; |
| |
| #[cfg(target_os = "fuchsia")] |
| impl ::fidl_next::HasTransport for Protocol { |
| type Transport = ::fidl_next::fuchsia::zx::Channel; |
| } |
| |
| pub mod protocol { |
| pub mod prelude { |
| pub use crate::{Protocol, ProtocolClientHandler, ProtocolServerHandler, protocol}; |
| } |
| |
| pub struct Foo; |
| |
| impl ::fidl_next::Method for Foo { |
| const ORDINAL: u64 = 6231434419097198905; |
| const FLEXIBILITY: ::fidl_next::protocol::Flexibility = |
| ::fidl_next::protocol::Flexibility::Strict; |
| |
| type Protocol = crate::Protocol; |
| |
| type Request = (); |
| } |
| |
| mod ___detail { |
| unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Protocol |
| where |
| ___T: ::fidl_next::Transport, |
| { |
| type Client = ProtocolClient<___T>; |
| type Server = ProtocolServer<___T>; |
| } |
| |
| /// The client for the `Protocol` protocol. |
| #[repr(transparent)] |
| pub struct ProtocolClient<___T: ::fidl_next::Transport> { |
| #[allow(dead_code)] |
| client: ::fidl_next::protocol::Client<___T>, |
| } |
| |
| impl<___T> ProtocolClient<___T> |
| where |
| ___T: ::fidl_next::Transport, |
| { |
| pub fn foo(&self) -> ::fidl_next::SendFuture<'_, ___T> { |
| ::fidl_next::SendFuture::from_untyped(self.client.send_one_way( |
| 6231434419097198905, |
| <super::Foo as ::fidl_next::Method>::FLEXIBILITY, |
| (), |
| )) |
| } |
| } |
| |
| /// The server for the `Protocol` protocol. |
| #[repr(transparent)] |
| pub struct ProtocolServer<___T: ::fidl_next::Transport> { |
| server: ::fidl_next::protocol::Server<___T>, |
| } |
| |
| impl<___T> ProtocolServer<___T> where ___T: ::fidl_next::Transport {} |
| } |
| } |
| |
| /// A client handler for the Protocol protocol. |
| /// |
| /// See [`Protocol`] for more details. |
| pub trait ProtocolClientHandler< |
| #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel, |
| #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport, |
| > |
| { |
| fn on_unknown_interaction( |
| &mut self, |
| ordinal: u64, |
| ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send { |
| ::core::future::ready(()) |
| } |
| } |
| |
| impl<___T> ProtocolClientHandler<___T> for ::fidl_next::IgnoreEvents |
| where |
| ___T: ::fidl_next::Transport, |
| { |
| async fn on_unknown_interaction(&mut self, _: u64) {} |
| } |
| |
| impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Protocol |
| where |
| ___H: ProtocolClientHandler<___T> + ::core::marker::Send, |
| ___T: ::fidl_next::Transport, |
| { |
| 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 => { |
| handler.on_unknown_interaction(ordinal).await; |
| if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) { |
| Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)) |
| } else { |
| Ok(()) |
| } |
| } |
| } |
| } |
| } |
| |
| /// A server handler for the Protocol protocol. |
| /// |
| /// See [`Protocol`] for more details. |
| pub trait ProtocolServerHandler< |
| #[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) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send; |
| |
| fn on_unknown_interaction( |
| &mut self, |
| ordinal: u64, |
| ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send { |
| ::core::future::ready(()) |
| } |
| } |
| |
| impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Protocol |
| where |
| ___H: ProtocolServerHandler<___T> + ::core::marker::Send, |
| ___T: ::fidl_next::Transport, |
| { |
| 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 { |
| 6231434419097198905 => { |
| handler.foo().await; |
| Ok(()) |
| } |
| |
| ordinal => { |
| handler.on_unknown_interaction(ordinal).await; |
| if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) { |
| Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)) |
| } else { |
| Ok(()) |
| } |
| } |
| } |
| } |
| |
| 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 { |
| ordinal => { |
| handler.on_unknown_interaction(ordinal).await; |
| if ::core::matches!(flexibility, ::fidl_next::protocol::Flexibility::Strict) { |
| Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)) |
| } else { |
| responder |
| .respond( |
| ordinal, |
| flexibility, |
| ::fidl_next::Flexible::<()>::FrameworkErr( |
| ::fidl_next::FrameworkError::UnknownMethod, |
| ), |
| ) |
| .expect("encoding a framework error should never fail") |
| .await?; |
| Ok(()) |
| } |
| } |
| } |
| } |
| } |
| |
| /// Compatibility shims which mimic some API surfaces of the current Rust bindings. |
| pub mod compat { |
| |
| impl ::fidl_next::CompatFrom<crate::Bits> for ::fidl_test_versions::Bits { |
| fn compat_from(value: crate::Bits) -> Self { |
| Self::from_bits_retain(value.bits()) |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<::fidl_test_versions::Bits> for crate::Bits { |
| fn compat_from(value: ::fidl_test_versions::Bits) -> Self { |
| Self::from_bits_retain(value.bits()) |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<crate::Enum> for ::fidl_test_versions::Enum { |
| fn compat_from(value: crate::Enum) -> Self { |
| match value { |
| crate::Enum::A => Self::A, |
| |
| crate::Enum::UnknownOrdinal_(unknown_ordinal) => { |
| Self::__SourceBreaking { unknown_ordinal } |
| } |
| } |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<::fidl_test_versions::Enum> for crate::Enum { |
| fn compat_from(value: ::fidl_test_versions::Enum) -> Self { |
| match value { |
| ::fidl_test_versions::Enum::A => Self::A, |
| |
| ::fidl_test_versions::Enum::__SourceBreaking { unknown_ordinal: value } => { |
| Self::UnknownOrdinal_(value) |
| } |
| } |
| } |
| } |
| |
| #[cfg(target_os = "fuchsia")] |
| /// An alias for a client over `zx::Channel` for the `OtherProtocol` |
| /// protocol. |
| pub type OtherProtocolProxy = ::fidl_next::Client<crate::OtherProtocol>; |
| |
| impl ::fidl_next::CompatFrom<crate::OtherProtocol> for ::fidl_test_versions::OtherProtocolMarker { |
| fn compat_from(_: crate::OtherProtocol) -> Self { |
| Self |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<::fidl_test_versions::OtherProtocolMarker> for crate::OtherProtocol { |
| fn compat_from(_: ::fidl_test_versions::OtherProtocolMarker) -> Self { |
| Self |
| } |
| } |
| |
| #[cfg(target_os = "fuchsia")] |
| |
| impl ::fidl_next::ClientCompatFrom<::fidl_test_versions::OtherProtocolProxy> |
| for crate::OtherProtocol |
| { |
| fn client_compat_from( |
| proxy: ::fidl_test_versions::OtherProtocolProxy, |
| ) -> ::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) |
| } |
| } |
| |
| #[cfg(target_os = "fuchsia")] |
| /// An alias for a client over `zx::Channel` for the `Protocol` |
| /// protocol. |
| pub type ProtocolProxy = ::fidl_next::Client<crate::Protocol>; |
| |
| impl ::fidl_next::CompatFrom<crate::Protocol> for ::fidl_test_versions::ProtocolMarker { |
| fn compat_from(_: crate::Protocol) -> Self { |
| Self |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<::fidl_test_versions::ProtocolMarker> for crate::Protocol { |
| fn compat_from(_: ::fidl_test_versions::ProtocolMarker) -> Self { |
| Self |
| } |
| } |
| |
| #[cfg(target_os = "fuchsia")] |
| |
| impl ::fidl_next::ClientCompatFrom<::fidl_test_versions::ProtocolProxy> for crate::Protocol { |
| fn client_compat_from( |
| proxy: ::fidl_test_versions::ProtocolProxy, |
| ) -> ::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) |
| } |
| } |
| } |