wasmtime_wasi/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! # Wasmtime's WASI Implementation
4//!
5//! This crate provides a Wasmtime host implementations of different versions of WASI.
6//! WASI is implemented with the Rust crates [`tokio`] and [`cap-std`](cap_std) primarily, meaning that
7//! operations are implemented in terms of their native platform equivalents by
8//! default.
9//!
10//! For components and WASIp2, see [`p2`].
11//! For WASIp1 and core modules, see the [`p1`] module documentation.
12//!
13//! For WASIp3, see [`p3`]. WASIp3 support is experimental, unstable and incomplete.
14
15/// The maximum size, in bytes, that this crate will allocate on the host on a
16/// per-read basis.
17///
18/// This is used to limit the size of `wasi:io/streams.input-stream#read`, for
19/// example, along with a variety of other read-style APIs. All of these APIs
20/// have the shape where the guest asks the host to read some data for it, and
21/// then it's returned. The data is allocated on the host, however, meaning that
22/// when the guest asks for an extremely large read that could cause a very
23/// large allocations on the host. For now this constant serves as a hard limit
24/// on the size of the allocation a host will make.
25///
26/// TODO: make this configurable per-I/O? Per-WASI? It's not great that this
27/// just a hard and unconfigurable limit. There are probably situations where
28/// performance will be improved if this limit were higher or removed. Doing so
29/// without exposing hosts to guest-controlled resource exhaustion is the
30/// important part, though.
31const MAX_READ_SIZE_ALLOC: usize = 64 * 1024;
32
33pub mod cli;
34pub mod clocks;
35mod ctx;
36mod error;
37pub mod filesystem;
38#[cfg(feature = "p1")]
39pub mod p0;
40#[cfg(feature = "p1")]
41pub mod p1;
42// FIXME: should gate this module on the `p2` feature but that will require more
43// internal refactoring to get that aligned right.
44// #[cfg(feature = "p2")]
45pub mod p2;
46#[cfg(feature = "p3")]
47pub mod p3;
48pub mod random;
49pub mod runtime;
50pub mod sockets;
51mod view;
52
53pub use self::clocks::{HostMonotonicClock, HostWallClock};
54pub use self::ctx::{WasiCtx, WasiCtxBuilder};
55pub use self::error::{I32Exit, TrappableError};
56pub use self::filesystem::{DirPerms, FilePerms, OpenMode};
57pub use self::random::{Deterministic, thread_rng};
58pub use self::view::{WasiCtxView, WasiView};
59#[doc(no_inline)]
60pub use async_trait::async_trait;
61#[doc(no_inline)]
62pub use cap_fs_ext::SystemTimeSpec;
63#[doc(no_inline)]
64pub use cap_rand::RngCore;
65#[doc(no_inline)]
66pub use wasmtime::component::{ResourceTable, ResourceTableError};