Path: blob/main/crates/wasi-common/src/snapshots/mod.rs
1692 views
//! One goal of `wasi-common` is for multiple WASI snapshots to provide an1//! interface to the same underlying `crate::WasiCtx`. This provides us a path2//! to evolve WASI by allowing the same WASI Command to import functions from3//! different snapshots - e.g. the user could use Rust's `std` which imports4//! snapshot 1, but also depend directly on the `wasi` crate which imports5//! some future snapshot 2. Right now, this amounts to supporting snapshot 16//! and "snapshot 0" aka wasi_unstable at once.7//!8//! The architectural rules for snapshots are:9//!10//! * Snapshots are arranged into modules under `crate::snapshots::`.11//! * Each snapshot should invoke `wiggle::from_witx!` with `ctx:12//! crate::WasiCtx` in its module, and impl all of the required traits.13//! * Snapshots can be implemented in terms of other snapshots. For example,14//! snapshot 0 is mostly implemented by calling the snapshot 1 implementation,15//! and converting its own types back and forth with the snapshot 1 types. In a16//! few cases, that is not feasible, so snapshot 0 carries its own17//! implementations in terms of the `WasiFile` and `WasiSched` traits.18//! * Snapshots can be implemented in terms of the `Wasi*` traits given by19//! `WasiCtx`. No further downcasting via the `as_any` escape hatch is20//! permitted.2122pub mod preview_0;23pub mod preview_1;242526