#client #wasm-pkg-client

wasm-pkg-client

Wasm package client

16 releases (5 breaking)

0.10.0 Jan 31, 2025
0.9.0 Dec 10, 2024
0.8.5 Nov 20, 2024
0.8.2 Oct 30, 2024
0.5.1 Sep 6, 2024

#802 in WebAssembly

Download history 3849/week @ 2024-12-16 2135/week @ 2024-12-23 1533/week @ 2024-12-30 2274/week @ 2025-01-06 1771/week @ 2025-01-13 1855/week @ 2025-01-20 2631/week @ 2025-01-27 1976/week @ 2025-02-03 1910/week @ 2025-02-10 2108/week @ 2025-02-17 1542/week @ 2025-02-24 1942/week @ 2025-03-03 3820/week @ 2025-03-10 3601/week @ 2025-03-17 2359/week @ 2025-03-24 2568/week @ 2025-03-31

12,543 downloads per month
Used in 12 crates (8 directly)

Apache-2.0 WITH LLVM-exception

135KB
2.5K SLoC

Wasm Package Client

Client implements a unified interface for loading package content from multiple kinds of package registries.

Example

// Initialize client from global configuration.
let mut client = wasm_pkg_client::Client::with_global_defaults().await?;

// Get a specific package release version.
let pkg = "example:pkg".parse()?;
let version = "1.0.0".parse()?;
let release = client.get_release(&pkg, &version).await?;

// Stream release content to a file.
let mut stream = client.stream_content(&pkg, &release).await?;
let mut file = tokio::fs::File::create("output.wasm").await?;
use futures_util::TryStreamExt;
use tokio::io::AsyncWriteExt;
while let Some(chunk) = stream.try_next().await? {
    file.write_all(&chunk).await?;
}

Wasm Package Client

A minimal Package Registry interface for multiple registry backends.

Running Tests

The e2e tests require an OCI Distribution Spec-compliant registry to be running at localhost:5000. An ephemeral registry can be run with:

$ docker run --rm -p 5000:5000 distribution/distribution:edge

The e2e tests themselves are in the separate tests/e2e crate:

$ cd tests/e2e
$ cargo run

Dependencies

~35–55MB
~1M SLoC