Skip to main content

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
6//! WASI. WASI is implemented with the Rust crate [`tokio`] combined with custom
7//! implementations in this crate, and operations are implemented in terms of
8//! their native platform equivalents by 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 default maximum size, in bytes, that this crate will allocate on the
16/// host on a per-read basis.
17///
18/// This is used throughout this crate as the default limiting factor for
19/// buffers allocated on the host for I/O reads, writes, etc. This can be
20/// overridden through `WasiCtxBuilder` in some situations, too.
21const MAX_READ_SIZE_ALLOC: usize = 64 * 1024;
22const DEFAULT_MAX_IO_SIZE: std::num::NonZeroUsize =
23    std::num::NonZeroUsize::new(MAX_READ_SIZE_ALLOC).unwrap();
24
25pub mod cli;
26pub mod clocks;
27mod ctx;
28mod error;
29pub mod filesystem;
30#[cfg(feature = "p1")]
31pub mod p0;
32#[cfg(feature = "p1")]
33pub mod p1;
34// FIXME: should gate this module on the `p2` feature but that will require more
35// internal refactoring to get that aligned right.
36// #[cfg(feature = "p2")]
37pub mod p2;
38#[cfg(feature = "p3")]
39pub mod p3;
40pub mod random;
41pub mod runtime;
42pub mod sockets;
43mod view;
44
45pub use self::clocks::{HostMonotonicClock, HostWallClock};
46pub use self::ctx::*;
47pub use self::error::{I32Exit, TrappableError};
48pub use self::filesystem::{FsPerms, OpenMode};
49pub use self::random::{Deterministic, thread_rng};
50pub use self::view::*;
51#[doc(no_inline)]
52pub use async_trait::async_trait;
53#[doc(no_inline)]
54pub use rand::Rng;
55#[doc(no_inline)]
56pub use wasmtime::component::{ResourceTable, ResourceTableError};