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#![warn(clippy::all)]
30#![deny(clippy::await_holding_lock)]
31#![deny(clippy::await_holding_refcell_ref)]
32
33mod runtime;
34pub use self::runtime::*;
35
36mod handle;
37pub use self::handle::channel::{Channel, RecvMsg};
38pub use self::handle::on_signals::OnSignalsRef;
39pub use self::handle::socket::Socket;
40
41/// Asynchronous networking abstractions.
42pub mod net;
43
44#[cfg(target_os = "fuchsia")]
45pub use self::handle::{
46    fifo::{Fifo, FifoEntry},
47    on_signals::OnSignals,
48    rwhandle::{RWHandle, ReadableHandle, ReadableState, WritableHandle, WritableState},
49};
50
51/// An emulation library for Zircon handles on non-Fuchsia platforms.
52#[cfg(not(target_os = "fuchsia"))]
53pub mod emulated_handle {
54    pub use super::handle::{
55        shut_down_handles, AsHandleRef, Channel, EmulatedHandleRef, Event, EventPair, Handle,
56        HandleBased, HandleDisposition, HandleInfo, HandleOp, HandleRef, Koid, MessageBuf,
57        MessageBufEtc, ObjectType, Peered, Rights, Signals, Socket, SocketOpts,
58    };
59
60    /// Type of raw Zircon handles.
61    #[allow(non_camel_case_types)]
62    pub type zx_handle_t = u32;
63}
64
65pub use fuchsia_async_macro::{run, run_singlethreaded, run_until_stalled};
66
67pub mod condition;
68/// Testing support for repeated runs
69pub mod test_support;