| // DO NOT EDIT: This file is machine-generated by fidlgen |
| #![warn(clippy::all)] |
| #![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)] |
| |
| #[derive(PartialEq, Clone, Debug)] |
| pub struct ExampleFooRequest { |
| pub s: ::std::string::String, |
| } |
| |
| impl ::fidl_next::Encodable for ExampleFooRequest { |
| type Encoded = WireExampleFooRequest<'static>; |
| } |
| |
| unsafe impl<___E> ::fidl_next::Encode<___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<Self::Encoded>, |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let Self::Encoded { |
| s, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(self.s, encoder_, s)?; |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<___E> ::fidl_next::EncodeRef<___E> for ExampleFooRequest |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| ___E: ::fidl_next::Encoder, |
| { |
| #[inline] |
| fn encode_ref( |
| &self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<Self::Encoded>, |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let Self::Encoded { |
| |
| s, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::EncodeRef::encode_ref(&self.s, encoder_, s)?; |
| |
| Ok(()) |
| } |
| } |
| |
| impl ::fidl_next::EncodableOption for ExampleFooRequest { |
| type EncodedOption = ::fidl_next::WireBox<'static, WireExampleFooRequest<'static>>; |
| } |
| |
| unsafe impl<___E> ::fidl_next::EncodeOption<___E> for ExampleFooRequest |
| where |
| ___E: ::fidl_next::Encoder + ?Sized, |
| ExampleFooRequest: ::fidl_next::Encode<___E>, |
| { |
| #[inline] |
| fn encode_option( |
| this: ::core::option::Option<Self>, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>, |
| ) -> ::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<___E> ::fidl_next::EncodeOptionRef<___E> for ExampleFooRequest |
| where |
| ___E: ::fidl_next::Encoder + ?Sized, |
| ExampleFooRequest: ::fidl_next::EncodeRef<___E>, |
| { |
| #[inline] |
| fn encode_option_ref( |
| this: ::core::option::Option<&Self>, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>, |
| ) -> ::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<WireExampleFooRequest<'de>> for ExampleFooRequest { |
| #[inline] |
| fn from_wire(wire: WireExampleFooRequest<'de>) -> Self { |
| Self { s: ::fidl_next::FromWire::from_wire(wire.s) } |
| } |
| } |
| |
| impl<'de> ::fidl_next::IntoNatural for WireExampleFooRequest<'de> { |
| type Natural = ExampleFooRequest; |
| } |
| |
| impl<'de> ::fidl_next::FromWireRef<WireExampleFooRequest<'de>> for ExampleFooRequest { |
| #[inline] |
| fn from_wire_ref(wire: &WireExampleFooRequest<'de>) -> Self { |
| Self { s: ::fidl_next::FromWireRef::from_wire_ref(&wire.s) } |
| } |
| } |
| |
| /// The wire type corresponding to [`ExampleFooRequest`]. |
| #[derive(Debug)] |
| #[repr(C)] |
| pub struct WireExampleFooRequest<'de> { |
| pub s: ::fidl_next::WireString<'de>, |
| } |
| static_assertions::const_assert_eq!(std::mem::size_of::<WireExampleFooRequest<'_>>(), 16); |
| static_assertions::const_assert_eq!(std::mem::align_of::<WireExampleFooRequest<'_>>(), 8); |
| |
| static_assertions::const_assert_eq!(std::mem::offset_of!(WireExampleFooRequest<'_>, s), 0); |
| |
| unsafe impl ::fidl_next::Wire for WireExampleFooRequest<'static> { |
| type Decoded<'de> = WireExampleFooRequest<'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 WireExampleFooRequest<'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_; |
| } |
| |
| ::fidl_next::Decode::decode(s.as_mut(), decoder_)?; |
| |
| Ok(()) |
| } |
| } |
| |
| #[derive(PartialEq, Clone, Debug)] |
| #[repr(C)] |
| pub struct ExampleFooResponse { |
| pub y: i64, |
| } |
| |
| impl ::fidl_next::Encodable for ExampleFooResponse { |
| const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireExampleFooResponse> = unsafe { |
| ::fidl_next::CopyOptimization::enable_if( |
| true && <i64 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(), |
| ) |
| }; |
| |
| type Encoded = WireExampleFooResponse; |
| } |
| |
| unsafe impl<___E> ::fidl_next::Encode<___E> for ExampleFooResponse |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<Self::Encoded>, |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let Self::Encoded { |
| y, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(self.y, encoder_, y)?; |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<___E> ::fidl_next::EncodeRef<___E> for ExampleFooResponse |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| { |
| #[inline] |
| fn encode_ref( |
| &self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<Self::Encoded>, |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let Self::Encoded { |
| |
| y, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::EncodeRef::encode_ref(&self.y, encoder_, y)?; |
| |
| Ok(()) |
| } |
| } |
| |
| impl ::fidl_next::EncodableOption for ExampleFooResponse { |
| type EncodedOption = ::fidl_next::WireBox<'static, WireExampleFooResponse>; |
| } |
| |
| unsafe impl<___E> ::fidl_next::EncodeOption<___E> for ExampleFooResponse |
| where |
| ___E: ::fidl_next::Encoder + ?Sized, |
| ExampleFooResponse: ::fidl_next::Encode<___E>, |
| { |
| #[inline] |
| fn encode_option( |
| this: ::core::option::Option<Self>, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>, |
| ) -> ::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<___E> ::fidl_next::EncodeOptionRef<___E> for ExampleFooResponse |
| where |
| ___E: ::fidl_next::Encoder + ?Sized, |
| ExampleFooResponse: ::fidl_next::EncodeRef<___E>, |
| { |
| #[inline] |
| fn encode_option_ref( |
| this: ::core::option::Option<&Self>, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>, |
| ) -> ::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<WireExampleFooResponse> for ExampleFooResponse { |
| const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireExampleFooResponse, 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: WireExampleFooResponse) -> Self { |
| Self { y: ::fidl_next::FromWire::from_wire(wire.y) } |
| } |
| } |
| |
| impl ::fidl_next::IntoNatural for WireExampleFooResponse { |
| type Natural = ExampleFooResponse; |
| } |
| |
| impl ::fidl_next::FromWireRef<WireExampleFooResponse> for ExampleFooResponse { |
| #[inline] |
| fn from_wire_ref(wire: &WireExampleFooResponse) -> Self { |
| Self { y: ::fidl_next::FromWireRef::from_wire_ref(&wire.y) } |
| } |
| } |
| |
| /// The wire type corresponding to [`ExampleFooResponse`]. |
| #[derive(Clone, Debug)] |
| #[repr(C)] |
| pub struct WireExampleFooResponse { |
| pub y: ::fidl_next::WireI64, |
| } |
| static_assertions::const_assert_eq!(std::mem::size_of::<WireExampleFooResponse>(), 8); |
| static_assertions::const_assert_eq!(std::mem::align_of::<WireExampleFooResponse>(), 8); |
| |
| static_assertions::const_assert_eq!(std::mem::offset_of!(WireExampleFooResponse, y), 0); |
| |
| unsafe impl ::fidl_next::Wire for WireExampleFooResponse { |
| type Decoded<'de> = WireExampleFooResponse; |
| |
| #[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 WireExampleFooResponse |
| 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_; |
| } |
| |
| ::fidl_next::Decode::decode(y.as_mut(), decoder_)?; |
| |
| Ok(()) |
| } |
| } |
| |
| /// The type corresponding to the Example protocol. |
| #[derive(PartialEq, Debug)] |
| pub struct Example; |
| |
| pub mod example { |
| pub mod prelude { |
| pub use crate::{Example, ExampleClientHandler, ExampleServerHandler, example}; |
| |
| pub use crate::ExampleFooRequest; |
| |
| pub use crate::ExampleFooResponse; |
| } |
| |
| pub struct Foo; |
| |
| impl ::fidl_next::Method for Foo { |
| const ORDINAL: u64 = 1107623248440401476; |
| |
| type Protocol = crate::Example; |
| |
| type Request = crate::WireExampleFooRequest<'static>; |
| |
| type Response = |
| ::fidl_next::WireResult<'static, crate::WireExampleFooResponse, ::fidl_next::WireU32>; |
| } |
| |
| mod ___detail { |
| |
| pub struct Foo<T0> { |
| s: T0, |
| } |
| |
| impl<T0> ::fidl_next::Encodable for Foo<T0> |
| where |
| T0: ::fidl_next::Encodable<Encoded = ::fidl_next::WireString<'static>>, |
| { |
| type Encoded = crate::WireExampleFooRequest<'static>; |
| } |
| |
| unsafe impl<___E, T0> ::fidl_next::Encode<___E> for Foo<T0> |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| ___E: ::fidl_next::Encoder, |
| T0: ::fidl_next::Encode<___E, Encoded = ::fidl_next::WireString<'static>>, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<Self::Encoded>, |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let Self::Encoded { |
| s, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(self.s, encoder_, s)?; |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<___T> ::fidl_next::Protocol<___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< |
| <___T as ::fidl_next::Transport>::SendBuffer, |
| Encoded = ::fidl_next::WireString<'static>, |
| >, |
| ) -> ::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(Foo { s }) |
| } |
| |
| pub fn foo_with<___R>( |
| &self, |
| request: ___R, |
| ) -> ::fidl_next::TwoWayFuture<'_, super::Foo, ___T> |
| where |
| ___R: ::fidl_next::Encode< |
| <___T as ::fidl_next::Transport>::SendBuffer, |
| Encoded = crate::WireExampleFooRequest<'static>, |
| >, |
| { |
| ::fidl_next::TwoWayFuture::from_untyped( |
| self.client.send_two_way(1107623248440401476, 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(not(feature = "fuchsia"))] ___T: ::fidl_next::Transport, |
| #[cfg(feature = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel, |
| > |
| { |
| } |
| |
| 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, |
| client: &::fidl_next::Client<Self, ___T>, |
| ordinal: u64, |
| buffer: ___T::RecvBuffer, |
| ) { |
| match ordinal { |
| ordinal => client.close(), |
| } |
| } |
| } |
| |
| /// A server handler for the Example protocol. |
| /// |
| /// See [`Example`] for more details. |
| pub trait ExampleServerHandler< |
| #[cfg(not(feature = "fuchsia"))] ___T: ::fidl_next::Transport, |
| #[cfg(feature = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel, |
| > |
| { |
| 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, |
| server: &::fidl_next::Server<Self, ___T>, |
| ordinal: u64, |
| buffer: ___T::RecvBuffer, |
| ) { |
| match ordinal { |
| ordinal => server.close(), |
| } |
| } |
| |
| async fn on_two_way( |
| handler: &mut ___H, |
| ordinal: u64, |
| buffer: ___T::RecvBuffer, |
| responder: ::fidl_next::protocol::Responder<___T>, |
| ) { |
| match ordinal { |
| 1107623248440401476 => { |
| let responder = ::fidl_next::Responder::from_untyped(responder); |
| |
| match ::fidl_next::DecoderExt::decode(buffer) { |
| Ok(decoded) => handler.foo(decoded, responder).await, |
| Err(e) => drop(responder), |
| } |
| } |
| |
| ordinal => responder.server().close(), |
| } |
| } |
| } |
| |
| /// 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) |
| } |
| } |
| } |