#distribution #registry #package #oci #client #cargo

wasm-pkg-client

Wasm package client

2 releases

0.5.1 Sep 6, 2024
0.5.0 Sep 5, 2024

#137 in WebAssembly

Download history 367/week @ 2024-09-01 305/week @ 2024-09-08

672 downloads per month
Used in 4 crates

Apache-2.0 WITH LLVM-exception

120KB
2.5K SLoC

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

lib.rs:

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()?;

// 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?;
}

Dependencies

~30–50MB
~777K SLoC