fuchsia_async/
lib.rs

1// Copyright 2018 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//! A futures-rs executor designed specifically for Fuchsia.
6//!
7//! # Example:
8//! A simple, singlethreaded print server:
9//!
10//! ```no_run
11//! #[fuchsia_async::run_singlethreaded]
12//! async fn main() {
13//!     let op = say_world();
14//!
15//!     // This println! will happen first
16//!     println!("Hello...");
17//!
18//!     // Calling `.await` on `op` starts executing `say_world`.
19//!     op.await;
20//! }
21//!
22//!
23//! async fn say_world() {
24//!     println!("...world");
25//! }
26//! ```
27
28#![warn(missing_docs)]
29#![deny(clippy::await_holding_lock)]
30#![deny(clippy::await_holding_refcell_ref)]
31
32mod runtime;
33pub use self::runtime::*;
34
35mod handle;
36pub use self::handle::channel::{Channel, RecvMsg};
37pub use self::handle::on_signals::OnSignalsRef;
38pub use self::handle::socket::Socket;
39
40/// Asynchronous networking abstractions.
41pub mod net;
42
43#[cfg(target_os = "fuchsia")]
44pub use self::handle::{
45    fifo::{Fifo, FifoEntry, FifoReadable, FifoWritable, ReadEntries, ReadOne, WriteEntries},
46    on_signals::OnSignals,
47    rwhandle::{RWHandle, ReadableHandle, ReadableState, WritableHandle, WritableState},
48};
49
50/// An emulation library for Zircon handles on non-Fuchsia platforms.
51#[cfg(not(target_os = "fuchsia"))]
52pub mod emulated_handle {
53    pub use super::handle::{
54        shut_down_handles, AsHandleRef, Channel, ChannelProxyProtocol, EmulatedHandleRef, Event,
55        EventPair, Handle, HandleBased, HandleDisposition, HandleInfo, HandleOp, HandleRef, Koid,
56        MessageBuf, MessageBufEtc, ObjectType, Peered, Rights, Signals, Socket, SocketOpts,
57    };
58
59    /// Type of raw Zircon handles.
60    #[allow(non_camel_case_types)]
61    pub type zx_handle_t = u32;
62}
63
64pub use fuchsia_async_macro::{run, run_singlethreaded, run_until_stalled};
65
66pub mod condition;
67/// Testing support for repeated runs
68pub mod test_support;