1#[cfg(feature = "fuchsia")]
6use fidl_next_codec::CompatFrom;
7
8#[cfg(feature = "fuchsia")]
9use crate::Client;
10use crate::{ClientEnd, ServerEnd};
11
12macro_rules! impl_compat_from_for_endpoints {
13 ($($endpoint:ident),* $(,)?) => { $(
14 impl<P1, P2, T> ::fidl_next_codec::CompatFrom<$endpoint<P1, T>> for ::fidl::endpoints::$endpoint<P2>
15 where
16 ::fidl::Channel: ::fidl_next_codec::CompatFrom<T>,
17 P2: ::fidl_next_codec::CompatFrom<P1>,
18 {
19 fn compat_from(value: $endpoint<P1, T>) -> Self {
20 Self::new(::fidl::Channel::compat_from(value.into_untyped()))
21 }
22 }
23
24 impl<P1, P2, T> ::fidl_next_codec::CompatFrom<::fidl::endpoints::$endpoint<P1>> for $endpoint<P2, T>
25 where
26 T: ::fidl_next_codec::CompatFrom<::fidl::Channel>,
27 P2: ::fidl_next_codec::CompatFrom<P1>,
28 {
29 fn compat_from(value: ::fidl::endpoints::$endpoint<P1>) -> Self {
30 Self::from_untyped(T::compat_from(value.into_channel()))
31 }
32 }
33 )* };
34}
35
36impl_compat_from_for_endpoints!(ClientEnd, ServerEnd);
37
38#[cfg(feature = "fuchsia")]
39pub trait ClientCompatFrom<T>: Sized {
41 fn client_compat_from(proxy: T) -> Client<Self, zx::Channel>;
43}
44
45#[cfg(feature = "fuchsia")]
46impl<T, P> CompatFrom<T> for Client<P, zx::Channel>
47where
48 P: ClientCompatFrom<T>,
49{
50 fn compat_from(value: T) -> Self {
51 P::client_compat_from(value)
52 }
53}