wasi-dbms-memory 0.8.0

Memory provider and page management for wasm-dbms using WASI
Documentation

wasi-dbms-memory

logo

license-mit repo-stars downloads latest-version conventional-commits

ci coveralls docs

WASI file-backed MemoryProvider implementation for the wasm-dbms framework.

This crate provides WasiMemoryProvider, a persistent storage backend that uses a single flat file on the filesystem, enabling wasm-dbms to run on any WASI-compliant runtime (Wasmer, Wasmtime, WasmEdge, etc.) with durable data persistence.

Components

How It Works

The backing file is byte-for-byte equivalent to IC stable memory: a contiguous sequence of 64 KiB pages, zero-filled on allocation. This means database snapshots are portable across different MemoryProvider implementations.

  • new(path) opens or creates the file. Existing files have their page count inferred from file size. Non-page-aligned files are rejected.
  • grow(n) extends the file by n * 64 KiB zero-filled bytes.
  • read/write operate at arbitrary byte offsets with bounds checking.

Usage

use wasi_dbms_memory::WasiMemoryProvider;
use wasm_dbms::DbmsContext;

let provider = WasiMemoryProvider::new("./data/mydb.bin").unwrap();
let ctx = DbmsContext::new(provider, acl);
// use ctx with wasm-dbms as usual

License

This project is licensed under the MIT License. See the LICENSE file for details.