Skip to main content

Crate ipfrs_wasm

Crate ipfrs_wasm 

Source
Expand description

WebAssembly bindings for IPFRS

This module provides browser-compatible bindings for IPFRS using wasm-bindgen. Two storage backends are available:

  • IpfrsClient: in-memory (HashMap-backed), ephemeral — data is lost on page refresh.
  • IpfrsClientPersistent: IndexedDB-backed, browser-persistent (wasm32 only).

§Quick Start (JavaScript)

import init, { IpfrsClient, compute_cid, verify_cid, version } from './ipfrs_wasm.js';

const _wasm = await init();

// Ephemeral in-memory client
const client = new IpfrsClient();
const cid = await client.add(new TextEncoder().encode("hello ipfrs"));
const bytes = await client.get(cid);
console.log(new TextDecoder().decode(bytes));

// Persistent IndexedDB client (browser only)
const persistent = await IpfrsClientPersistent.new("ipfrs-blocks");
const cid2 = await persistent.add(new TextEncoder().encode("persisted data"));

Modules§

async_api
Async-friendly API types for IPFRS WASM bindings.
peer_state
WebRTC peer connection state machine.
storage
IndexedDB-compatible in-memory block store for wasm32.
webrtc
WebRTC transport for browser-to-browser peer connectivity.

Structs§

IpfrsClient
IPFRS in-memory client for WebAssembly.

Functions§

add_bytes
Add bytes using a temporary in-memory client and return the CID.
compute_cid
Compute the CIDv1 (base32-lower, SHA2-256, raw codec) for the given bytes without storing them.
get_bytes
Retrieve bytes from an IpfrsClient by CID.
start
Initialise the IPFRS WASM module.
verify_cid
Verify that data matches cid (i.e., recomputing the CID yields the same string).
version
Return the ipfrs-wasm version string.