bytecodealliance/wstd

A WebAssembly-native Rust stdlib

Rust

136

269 commits

updated Sep 22, 2026

See the code

README

wstd

An async Rust standard library for Wasm Components and WASI 0.2
A Bytecode Alliance project

This is a minimal async Rust standard library written exclusively to support Wasm Components. It exists primarily to enable people to write async-based applications in Rust before async-std, smol, or tokio land support for Wasm Components and WASI 0.2. Once those runtimes land support, it is recommended users switch to use those instead.

Examples

TCP echo server

use wstd::io;
use wstd::iter::AsyncIterator;
use wstd::net::TcpListener;
use wstd::runtime::block_on;

fn main() -> io::Result<()> {
    block_on(async move {
        let listener = TcpListener::bind("127.0.0.1:8080").await?;
        println!("Listening on {}", listener.local_addr()?);
        println!("type `nc localhost 8080` to create a TCP client");

        let mut incoming = listener.incoming();
        while let Some(stream) = incoming.next().await {
            let stream = stream?;
            println!("Accepted from: {}", stream.peer_addr()?);
            io::copy(&stream, &stream).await?;
        }
        Ok(())
    })
}

Installation

$ cargo add wstd

Safety

This crate uses #![deny(unsafe_code)], and in the very small number of exceptional cases where #[allow(unsafe_code)] is required, documentation is provided justifying its use.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

License

Licensed under Apache License, Version 2.0 with LLVM Exception.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license with LLVM Exception, shall be licensed as above, without any additional terms or conditions.

Contributors

pchickey

143 commits

sunfishcode

57 commits

yoshuawuyts

28 commits

adamrk

16 commits

bytecodealliance/wstd

A WebAssembly-native Rust stdlib

Rust

136

269 commits

updated Sep 22, 2026

See the code

README

wstd

An async Rust standard library for Wasm Components and WASI 0.2
A Bytecode Alliance project

This is a minimal async Rust standard library written exclusively to support Wasm Components. It exists primarily to enable people to write async-based applications in Rust before async-std, smol, or tokio land support for Wasm Components and WASI 0.2. Once those runtimes land support, it is recommended users switch to use those instead.

Examples

TCP echo server

use wstd::io;
use wstd::iter::AsyncIterator;
use wstd::net::TcpListener;
use wstd::runtime::block_on;

fn main() -> io::Result<()> {
    block_on(async move {
        let listener = TcpListener::bind("127.0.0.1:8080").await?;
        println!("Listening on {}", listener.local_addr()?);
        println!("type `nc localhost 8080` to create a TCP client");

        let mut incoming = listener.incoming();
        while let Some(stream) = incoming.next().await {
            let stream = stream?;
            println!("Accepted from: {}", stream.peer_addr()?);
            io::copy(&stream, &stream).await?;
        }
        Ok(())
    })
}

Installation

$ cargo add wstd

Safety

This crate uses #![deny(unsafe_code)], and in the very small number of exceptional cases where #[allow(unsafe_code)] is required, documentation is provided justifying its use.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

License

Licensed under Apache License, Version 2.0 with LLVM Exception.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license with LLVM Exception, shall be licensed as above, without any additional terms or conditions.

Contributors

pchickey

143 commits

sunfishcode

57 commits

yoshuawuyts

28 commits

adamrk

16 commits

Languages

Rust

100.0%