cap_std/
lib.rs

1//! A capability-based API modeled after [`std`].
2//!
3//! This corresponds to [`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(docsrs, feature(doc_cfg, doc_auto_cfg))]
27#![cfg_attr(target_os = "wasi", feature(wasi_ext))]
28#![cfg_attr(can_vector, feature(can_vector))]
29#![cfg_attr(write_all_vectored, feature(write_all_vectored))]
30#![doc(
31    html_logo_url = "https://raw.githubusercontent.com/bytecodealliance/cap-std/main/media/cap-std.svg"
32)]
33#![doc(
34    html_favicon_url = "https://raw.githubusercontent.com/bytecodealliance/cap-std/main/media/cap-std.ico"
35)]
36#![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
37
38pub mod fs;
39#[cfg(feature = "fs_utf8")]
40pub mod fs_utf8;
41#[cfg(not(target_os = "wasi"))] // Disable `net` on WASI until it has networking support.
42pub mod net;
43pub mod os;
44pub mod time;
45// Re-export ambient_authority etc. so that users can use our version.
46#[doc(hidden)]
47pub use cap_primitives::ambient_authority_known_at_compile_time;
48pub use cap_primitives::{ambient_authority, AmbientAuthority};
49// And these are also part of our public API
50pub use cap_primitives::ipnet;
51pub use io_lifetimes;