cap_async_std/
lib.rs

1//! A capability-based API modeled after [`async_std`].
2//!
3//! This corresponds to [`async_std`].
4//!
5//! Capability-based APIs represent access to external resources as values
6//! which can be passed around between different parts of a program.
7//!
8//! Two notable features are the [`Dir`] and [`Pool`] types:
9//!  - `Dir` represents an open directory in a filesystem. Instead of opening
10//!    files by absolute paths or paths relative to the current working
11//!    directory, files are opened via paths relative to a `Dir`. The concepts
12//!    of a process-wide "current working directory" and a single global
13//!    filesystem namespace are de-emphasized.
14//!  - `Pool` represents a set of network addresses. Instead of allowing
15//!    applications to request access to any address and then applying
16//!    process-wide filtering rules, filtering rules are built into pools which
17//!    may be passed through the program.
18//!
19//! On WASI, use of this library closely reflects the underlying system
20//! API, so it avoids compatibility layers.
21//!
22//! [`Dir`]: fs::Dir
23//! [`Pool`]: net::Pool
24
25#![deny(missing_docs)]
26#![cfg_attr(target_os = "wasi", feature(wasi_ext))]
27// async_std doesn't have "can_vector".
28// async_std doesn't have "write_all_vectored".
29#![doc(
30    html_logo_url = "https://raw.githubusercontent.com/bytecodealliance/cap-std/main/media/cap-std.svg"
31)]
32#![doc(
33    html_favicon_url = "https://raw.githubusercontent.com/bytecodealliance/cap-std/main/media/cap-std.ico"
34)]
35#![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
36
37pub mod fs;
38#[cfg(feature = "fs_utf8")]
39pub mod fs_utf8;
40#[cfg(not(target_os = "wasi"))] // Disable `net` on WASI until it has networking support.
41pub mod net;
42pub mod os;
43pub mod time;
44#[doc(hidden)]
45pub use cap_primitives::ambient_authority_known_at_compile_time;
46pub use cap_primitives::{ambient_authority, AmbientAuthority};
47
48// Re-export `async_std` to make it easy for users to depend on the same
49// version we do, because we use its types in our public API.
50pub use async_std;
51// And these are also part of our public API
52pub use cap_primitives::ipnet;
53pub use io_lifetimes;