Skip to main content

flex_client/
flex.rs

1// Copyright 2025 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#[cfg(feature = "fdomain")]
6pub use fdomain_client::*;
7
8#[cfg(feature = "fdomain")]
9pub type Dialect = fdomain_client::fidl::FDomainResourceDialect;
10
11#[cfg(not(feature = "fdomain"))]
12pub type Dialect = ::fidl::encoding::DefaultFuchsiaResourceDialect;
13
14#[cfg(feature = "fdomain")]
15pub use fdomain_client::Channel as AsyncChannel;
16
17#[cfg(feature = "fdomain")]
18pub use fdomain_client::Socket as AsyncSocket;
19
20#[cfg(feature = "fdomain")]
21pub fn socket_to_async(s: AsyncSocket) -> AsyncSocket {
22    s
23}
24
25#[cfg(not(feature = "fdomain"))]
26pub fn socket_to_async(s: Socket) -> AsyncSocket {
27    AsyncSocket::from_socket(s)
28}
29
30#[cfg(feature = "fdomain")]
31pub fn channel_to_async(s: AsyncChannel) -> AsyncChannel {
32    s
33}
34
35#[cfg(not(feature = "fdomain"))]
36pub fn channel_to_async(s: Channel) -> AsyncChannel {
37    AsyncChannel::from_channel(s)
38}
39
40#[cfg(not(feature = "fdomain"))]
41pub use ::fidl::endpoints::ProxyHasDomain;
42
43#[cfg(feature = "fdomain")]
44pub use fdomain_client::fidl::Proxy as ProxyHasDomain;
45
46#[cfg(not(feature = "fdomain"))]
47pub use ::fidl::*;
48
49#[cfg(not(feature = "fdomain"))]
50pub use zx::MessageBuf;
51
52#[cfg(feature = "fdomain")]
53pub type NullableHandle = fdomain_client::Handle;
54
55#[cfg(not(feature = "fdomain"))]
56pub mod fidl {
57    pub use ::fidl::endpoints::*;
58}
59
60#[cfg(feature = "fdomain")]
61pub type ClientArg = std::sync::Arc<fdomain_client::Client>;
62#[cfg(not(feature = "fdomain"))]
63pub type ClientArg = ::fidl::endpoints::ZirconClient;
64
65#[cfg(not(feature = "fdomain"))]
66pub async fn wait_for_signals(
67    handle: &impl AsHandleRef,
68    signals: ::fidl::Signals,
69) -> Result<::fidl::Signals, ::fidl::Status> {
70    fuchsia_async::OnSignalsRef::new(handle.as_handle_ref(), signals).await
71}
72
73#[cfg(feature = "fdomain")]
74pub async fn wait_for_signals(
75    handle: &Handle,
76    signals: ::fidl::Signals,
77) -> Result<::fidl::Signals> {
78    OnFDomainSignals::new(handle, signals).await
79}