Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: bytecodealliance/wstd
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: bytecodealliance/wstd
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: p3
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 16 commits
  • 65 files changed
  • 2 contributors

Commits on Jun 9, 2026

  1. Move wasip2 impl into src/sys/p2 (pure relocation)

    This is a pure `git mv` relocation with no content changes, so git
    records clean renames and `git blame`/`--follow` lineage is preserved.
    The build is intentionally red after this commit; backend wiring and
    crate-root re-export shims are added in the following commit.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jun 9, 2026
    Configuration menu
    Copy the full SHA
    cbd2a40 View commit details
    Browse the repository at this point in the history
  2. Wire up the src/sys backend with crate-root re-export shims

    Restores a green build after the pure relocation. The crate root now
    selects a platform backend via a single cfg-if in src/sys/mod.rs, and
    each moved module is re-exported through a thin shim so the public API
    is preserved exactly:
    
    * add `mod sys` plus src/sys/mod.rs (cfg-if) and src/sys/p2/mod.rs
    * add crate-root shims: http.rs, net.rs, rand.rs, runtime.rs, time.rs
    * re-export the moved stdio/streams via src/sys/p2/io and io/mod.rs
    * repoint the few internal `super::`/private-module paths the move broke
    * add the cfg-if dependency
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jun 9, 2026
    Configuration menu
    Copy the full SHA
    19f2f24 View commit details
    Browse the repository at this point in the history
  3. Document the backend contract and assert it at compile time

    Spell out, in `src/sys/mod.rs`, the duck-typed contract each `src/sys`
    backend must satisfy so the crate-root modules can be target-agnostic
    facades. Add a private `const _` block that statically checks the parts
    the facades depend on (the IO stream traits today), so backend drift
    fails fast with a clear message instead of surfacing deep inside a
    facade.
    
    No behavior or public-API change.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jun 9, 2026
    Configuration menu
    Copy the full SHA
    5d4f2c5 View commit details
    Browse the repository at this point in the history
  4. Turn time into a cfg-free facade over a small clock contract

    Promote the portable time types — `Duration`, `Instant`, `Interval`,
    `interval`, `Timer`, `Wait`, and the crate-internal `utils::timeout_err`
    — out of the wasip2 backend and into the `crate::time` facade, where
    they are written once with no `#[cfg]` and own all of their own
    arithmetic.
    
    The wasip2 backend (`src/sys/p2/time`) keeps only the primitives that
    genuinely depend on the WASI 0.2 clocks: the `MonotonicInstant` /
    `MonotonicDuration` nanosecond aliases, `now`, `SystemTime`, and a
    `Sleep` future built by `sleep_until`. `Timer` now records its deadline
    at construction (`TimerKind::{Never, At}`) and builds a fresh backend
    `Sleep` on each `wait`, so a second backend (p3) only has to supply a
    different `Sleep`/`sleep_until` rather than re-implementing the facade.
    
    Extend the backend-contract assertions in `src/sys/mod.rs` accordingly.
    Public API is unchanged.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jun 9, 2026
    Configuration menu
    Copy the full SHA
    0c6bca1 View commit details
    Browse the repository at this point in the history
  5. Hoist the portable rand surface into a facade

    The length guard and slice copy in `get_random_bytes` /
    `get_insecure_random_bytes` are identical across backends; only the host
    RNG call differs. Move the two public functions up into the `crate::rand`
    facade and reduce the wasip2 backend to `random_bytes` /
    `insecure_random_bytes` primitives that return the raw bytes.
    
    Public API is unchanged.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jun 9, 2026
    Configuration menu
    Copy the full SHA
    5428a40 View commit details
    Browse the repository at this point in the history
  6. Hoist the portable runtime executor surface into a facade

    `spawn` and the `async_task::Task` re-export are identical across
    backends; only `block_on` and the `Reactor` internals are platform
    specific. Move `spawn` and `Task` up into the `crate::runtime` facade
    and re-export `block_on`/`Reactor`/`AsyncPollable`/`WaitFor` from the
    wasip2 backend. `REACTOR` and `Reactor` stay in the backend.
    
    Public API is unchanged.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jun 9, 2026
    Configuration menu
    Copy the full SHA
    e030a6a View commit details
    Browse the repository at this point in the history
  7. Hoist the portable http surface into a facade

    Convert `src/http.rs` from a blanket `pub use crate::sys::http::*` shim into a
    real facade: it owns the portable surface (`StatusCode`, `Uri`/`Authority`/
    `PathAndQuery`, the `error` module of `anyhow`/`http`-crate error types, and the
    `body`/`request`/`response`/`server` public submodule paths) and re-exports the
    backend's concrete types (`Client`, `Method`, `Scheme`, `HeaderMap`, `Body`,
    ...) through `crate::sys::http::*`. This keeps every public path identical while
    moving the target-agnostic shape out of the backend, so a future p3 backend only
    has to supply the platform pieces.
    
    The backend `sys::p2::http` now exposes just the platform impl: submodules with
    `pub`/`pub(crate)` visibility plus `pub use wasip2::http::types::{ErrorCode,
    HeaderError}`. Its impl files import the public error/value types from the facade
    (`crate::http::*`) instead of the removed backend-level re-exports, and the
    public `server` module doc moves up to the facade.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jun 9, 2026
    Configuration menu
    Copy the full SHA
    1e978e1 View commit details
    Browse the repository at this point in the history

Commits on Jul 3, 2026

  1. Turn net into a facade that delegates to the backend

    `src/net.rs` was a blanket `pub use crate::sys::net::*`. Make it a real
    facade: declare the crate's public network surface -- `TcpStream`,
    `TcpListener`, `ReadHalf`, `WriteHalf`, `Incoming` -- as thin wrappers at the
    crate root that delegate every operation to the selected backend's
    implementation under `crate::sys::net`.
    
    The one genuinely portable piece, `TcpStream::connect`'s `ToSocketAddrs`
    resolve-and-retry loop, is written once here against the backend's
    `connect_addr` primitive (removed from the backend), so a second backend
    inherits it for free. Socket-shutdown cleanup still runs through the inner
    backend handles' own `Drop`; the facade keeps explicit `Drop` impls so the
    public drop contract is unchanged.
    
    Public API is unchanged.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jul 3, 2026
    Configuration menu
    Copy the full SHA
    efeaeea View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    da219b9 View commit details
    Browse the repository at this point in the history
  3. Target CI at wasm32-wasip2 for the wasip2-only crates

    Now that `wstd` and `wstd-axum` only compile for `wasm32-wasip2` (the `sys`
    backend is cfg-gated and other targets hit `compile_error!`), the CI steps that
    built them for the host target fail to resolve `crate::sys::*`. Scope those
    steps to the target:
    
    - `check` and `Clippy` build `wstd`/`wstd-axum` with `--target wasm32-wasip2
      --all-targets` and keep the `test-programs` host harness on the host.
    - `Docs` builds with `--target wasm32-wasip2`.
    - `ci/publish.rs` passes `--target wasm32-wasip2` when packaging `wstd` and
      `wstd-axum`.
    
    `--all-targets` newly lints the `#[cfg(test)]` code, so regroup the digit
    literals in the `time` duration tests to satisfy `inconsistent_digit_grouping`.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jul 3, 2026
    Configuration menu
    Copy the full SHA
    1200707 View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2026

  1. add p3 support

    yoshuawuyts committed Jul 19, 2026
    Configuration menu
    Copy the full SHA
    b3f4c06 View commit details
    Browse the repository at this point in the history
  2. fix p3 support

    yoshuawuyts committed Jul 19, 2026
    Configuration menu
    Copy the full SHA
    8aeb515 View commit details
    Browse the repository at this point in the history
  3. fix p3 example compilation and wstd-axum json feature

    Resolve the test failures introduced by the p2/p3 refactor:
    
    - wstd-axum: add a `json` feature (enabled by default) that turns on
      `wstd/json`. The switch to `default-features = false` had dropped json,
      breaking the weather example's `Body::json()`.
    - p3 time: make `Wait` hold a `Send` future so streaming response bodies
      (which await `task::sleep`) satisfy `Body::from_try_stream`'s `Send`
      bound. Fixes the `http_server` example under wasip3.
    - p3 net: give `TcpStream`/`TcpListener` interior mutability so they expose
      the same shared-reference API as p2 (`io::copy(&stream, &stream)`,
      `incoming(&self)`), add `TcpStream::peer_addr`, and replace the unsound
      raw-pointer `split` with safe shared references. Fixes the
      `tcp_echo_server` example under wasip3.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jul 19, 2026
    Configuration menu
    Copy the full SHA
    539fa50 View commit details
    Browse the repository at this point in the history
  4. p3: async-lift wasi:cli/run for #[wstd::main] instead of block_on

    Under WASIp3 a synchronous `wasi:cli/run` task cannot block on
    async-lowered imports: `block_on` (driven by `waitable-set.wait`) traps
    with "cannot block a synchronous task before returning". So `block_on`
    stays a p2-only concept.
    
    For p3, `#[wstd::main]` now async-lifts the export the same way
    `#[wstd::http_server]` does: it implements the async `wasi:cli/run`
    guest directly and exports it via `wasip3::cli::command::export!`, so
    the body can `.await` async-lowered imports (timers, sockets, http)
    without trapping. The bin's `fn main` remains as a dead entry point.
    
    The proc macro now delegates to a cfg-split `__main_export!` declarative
    macro in wstd (p2 keeps block_on; p3 async-lifts), mirroring
    `__http_server_export!`, so the `wstd_p2`/`wstd_p3` cfg aliases are
    evaluated in wstd's context for downstream consumers. A `__MainReturn`
    helper maps `()` / `Result<(), E: Debug>` to the `Result<(), ()>` the
    export requires, printing errors to stderr on failure.
    
    Also apply a pending rustfmt fix to src/sys/p3/io.rs.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jul 19, 2026
    Configuration menu
    Copy the full SHA
    889ec7b View commit details
    Browse the repository at this point in the history
  5. adapt p3 backend to modular facades

    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    yoshuawuyts and Copilot committed Jul 19, 2026
    Configuration menu
    Copy the full SHA
    be2d331 View commit details
    Browse the repository at this point in the history
  6. remove cfg_aliases

    yoshuawuyts committed Jul 19, 2026
    Configuration menu
    Copy the full SHA
    c6232ea View commit details
    Browse the repository at this point in the history
Loading