MCPcopy Index your code
hub / github.com/bytecodealliance/wstd

github.com/bytecodealliance/wstd @v0.6.7

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.7 ↗ · + Follow
337 symbols 678 edges 68 files 87 documented · 26%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

wstd

An async Rust standard library for Wasm Components and WASI 0.2

A Bytecode Alliance project

Crates.io version

Download

docs.rs docs

API Docs | Releases | Contributing

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.

Extension points exported contracts — how you extend this code

AsyncRead (Interface)
Read bytes from a source. [8 implementers]
src/io/read.rs
AsyncIterator (Interface)
Composable async iteration. A trait for dealing with async iterators. [2 implementers]
src/iter/mod.rs
FutureExt (Interface)
Extend `Future` with time-based operations. [1 implementers]
src/future/future_ext.rs
AsyncWrite (Interface)
Write bytes to a sink. [11 implementers]
src/io/write.rs
AsyncSeek (Interface)
The `Seek` trait provides a cursor which can be moved within a stream of bytes. [1 implementers]
src/io/seek.rs

Core symbols most depended-on inside this repo

get
called by 23
aws-example/src/bin/s3.rs
wait_for
called by 17
src/runtime/reactor.rs
send
called by 16
src/http/body.rs
next
called by 15
src/time/mod.rs
schedule
called by 14
src/runtime/reactor.rs
write_all
called by 11
src/io/streams.rs
empty
called by 10
src/io/empty.rs
block_on
called by 10
src/runtime/block_on.rs

Shape

Method 163
Function 110
Class 53
Enum 6
Interface 5

Languages

Rust100%

Modules by API surface

src/runtime/reactor.rs30 symbols
src/http/body.rs30 symbols
src/time/duration.rs20 symbols
src/io/streams.rs18 symbols
axum/examples/weather.rs18 symbols
src/io/stdio.rs17 symbols
src/time/mod.rs16 symbols
src/net/tcp_stream.rs14 symbols
ci/publish.rs14 symbols
examples/http_server.rs12 symbols
src/io/cursor.rs11 symbols
src/http/client.rs11 symbols

For agents

$ claude mcp add wstd \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact