Skip to main content

molt_registry_client/
lib.rs

1//! Molt WASM-aware registry client.
2//!
3//! This crate is a thin, WASM-focused extension on top of [`oci-client`]
4//! (oras-project/rust-oci-client).
5//!
6//! It supports:
7//! - OCI Distribution API (`/v2`) helpers for pulling component wasm layers.
8//! - Molt extension API (`/wasm/v1`) helpers for WIT, interface index, and search.
9//!
10//! The Molt spec this targets is described in this repo's docs:
11//! - WIT referrers: `application/vnd.wasm.wit.v1+text`
12//! - `/wasm/v1` endpoints: `.../wit`, `.../interfaces`, `.../dependencies`, `/search`
13//!
14//! # Example (env-configured)
15//!
16//! ```no_run
17//! use molt_registry_client::{OciWasmClient, WasmV1Client, WitRequest};
18//!
19//! # async fn run() -> anyhow::Result<()> {
20//! let oci = OciWasmClient::from_env()?.expect("set MOLT_REGISTRY");
21//! let wasm = oci.pull_component_wasm("example/repo", "1.0.0").await?;
22//! println!("downloaded {} bytes", wasm.len());
23//!
24//! let wasm_v1 = WasmV1Client::from_env()?.expect("set MOLT_REGISTRY");
25//! let wit = wasm_v1
26//!     .wit_text("example/repo", "1.0.0", &WitRequest::default())
27//!     .await?;
28//! println!("{}", wit.text);
29//!
30//! # Ok(()) }
31//! ```
32
33mod media_types;
34mod oci;
35mod util;
36mod wasm_v1;
37
38pub use media_types::*;
39pub use oci::*;
40pub use util::RegistryEndpoint;
41pub use util::{auth_from_env, auth_from_header_line, sanitize_path_segment};
42pub use wasm_v1::*;