WASIX Rust SDK

Host WebAssembly PostgreSQL from Rust with memory or persistent directory storage.

Use oliphaunt-wasix when a Rust application hosts the WASIX PostgreSQL runtime. For native desktop PostgreSQL, use the native Rust SDK.

Install

[dependencies]
oliphaunt-wasix = "0.3.0"

The package resolves matching runtime assets for supported hosts. Use Rust 1.93 or later.

Run your first query

Create a complete src/main.rs:

use oliphaunt_wasix::Oliphaunt;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut db = Oliphaunt::open()?;
    let result = db.sql("SELECT $1::int4 AS answer").bind(42_i32).query()?;
    let answer: i32 = result.rows()[0].try_get("answer")?;
    println!("{answer}"); // 42
    db.close()?;
    Ok(())
}

Run with cargo run. The default database uses a memory filesystem and is discarded on close.

Keep data between runs

use oliphaunt_wasix::{DatabaseStorage, Oliphaunt};

let mut db = Oliphaunt::builder()
    .storage(DatabaseStorage::Directory("./data/notes".into()))
    .open()?;

Only one live owner can open a persistent root. Reopen the same path to access saved data.

Choose synchronous or async ownership

The synchronous Oliphaunt is not Send or Sync. Create, use, close, and drop it on the same OS thread. Use AsyncOliphaunt for a cloneable Send + Sync handle:

use oliphaunt_wasix::AsyncOliphaunt;

let db = AsyncOliphaunt::open().await?;
let result = db.query("SELECT 42::int4 AS answer").await?;
db.close().await?;

Async clones share one owner and session. Continue with the WASIX Rust guide, runtime behavior, or API reference.