Rust SDK

Run native PostgreSQL in Rust or Tauri with synchronous and asynchronous APIs.

Use oliphaunt for native desktop Rust and Tauri applications. Choose WASIX Rust when you want to host the WebAssembly runtime instead.

Install

Use Rust 1.93 or later. Add the crate to Cargo.toml:

[dependencies]
oliphaunt = "0.3.0"

The crate includes the matching native runtime for supported desktop targets. No environment variables or separate runtime download are needed for the default setup.

Run your first query

Create src/main.rs with a complete, synchronous example:

use oliphaunt::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 it with cargo run. The default database uses disposable temporary storage. Choose a persistent directory before saving application data.

Keep data between runs

Use this storage configuration instead of the disposable example above. Direct mode stays bound to its first root for the lifetime of the process; closing does not let the same process switch roots.

Open a stable directory for application data:

use oliphaunt::{DatabaseStorage, Oliphaunt};

let mut db = Oliphaunt::builder()
    .storage(DatabaseStorage::Directory("./app-data/main.oliphaunt".into()))
    .direct()
    .open()?;

Keep the handle in application state. Reopen the same path to access the data again.

Use an async application

Use AsyncOliphaunt when queries must not block an async executor:

use oliphaunt::AsyncOliphaunt;

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

The synchronous handle is Send but not Sync; it requires exclusive access. The async handle is cloneable, Send, and Sync. Clones share one session and execute work in order.

Continue with the Rust guide, Tauri integration, or API reference.