Skip to main content

Crate oliphaunt_wasix

Crate oliphaunt_wasix 

Source
Expand description

oliphaunt-wasix

Embedded Postgres for Rust tests and local apps.
Real PostgreSQL. Direct Rust API or a local Postgres URL.

Guide · Performance · Extensions · Dump & Upgrade · Runtime · Tauri

CI crates.io docs.rs MSRV License

oliphaunt-wasix brings the WASIX Oliphaunt/Postgres runtime to Rust with a small API. Open a database directly with Oliphaunt, or hand OliphauntServer to SQLx and any standard Postgres client. The release-built runtime is PostgreSQL 18.4. Cargo resolves the matching WASIX runtime and AOT artifact crates; applications do not download runtime assets at first database open.

§Add Postgres In One Minute ⚡

Already using SQLx or another Postgres client? The WASIX API shape is:

cargo add oliphaunt-wasix
use oliphaunt_wasix::OliphauntServer;
use sqlx::{Connection, Row};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let server = OliphauntServer::temporary_tcp()?;
    // For a persistent TCP server:
    // let server = OliphauntServer::builder().path("./.oliphaunt").start()?;
    let mut conn = sqlx::PgConnection::connect(&server.database_url()).await?;

    let row = sqlx::query("SELECT $1::int4 + 1 AS answer")
        .bind(41_i32)
        .fetch_one(&mut conn)
        .await?;
    assert_eq!(row.try_get::<i32, _>("answer")?, 42);

    conn.close().await?;
    server.shutdown()?;
    Ok(())
}

That’s it. Real PostgreSQL, no service setup.

§Why oliphaunt-wasix ✨

Postgres should be as easy to add to a Rust project as SQLite.

  • No service tax: no Docker, no local Postgres, no testcontainers.
  • 🔌 Use your real stack: SQLx, tokio-postgres, CLIs, and other clients connect through a normal local URL.
  • 🌉 Proxy included: expose an embedded database to non-Rust tools with oliphaunt-wasix-proxy.
  • 🧪 Clean tests: temporary databases are isolated, fast, and removed on drop.
  • 💾 Persistent apps: keep local app data across restarts when you want it.
  • 🧩 Extensions available: install exact extension release assets owned by your application.
  • 📦 Portable tools: enable the tools feature to resolve the matching oliphaunt-wasix-tools pg_dump and psql artifacts for logical backups, checks, and upgrade paths.
  • 🚀 Near-native feel: close to native Postgres, fully embedded.

§Near-Native Performance 🚀

Current local snapshot on Apple M1 Pro, 16 GB RAM, and macOS 26.4.1. Full numbers and reproduction steps live in the performance guide. Lower is better.

Operationnative pg + SQLxoliphaunt-wasix + SQLxvanilla Oliphaunt + SQLx
25,000 INSERTs in one transaction132.36 ms149.54 ms257.02 ms
25,000 INSERTs in one statement46.14 ms59.39 ms117.19 ms
25,000 INSERTs into an indexed table188.72 ms253.38 ms352.64 ms
5,000 indexed SELECTs81.39 ms125.31 ms203.05 ms
25,000 indexed UPDATEs351.05 ms578.96 ms720.63 ms

oliphaunt-wasix stays close to native Postgres while running entirely embedded and consistently performs better than vanilla Oliphaunt.

§Extensions 🧩

WASIX extensions are exact package artifacts. The base runtime does not include optional extension payloads. Applications select only the extension packages they use.

§Docs

Structs§

DatabaseError
DescribeQueryParam
DescribeQueryResult
DescribeResultField
EngineCapabilities
Capabilities advertised by the packaged WASIX runtime.
ExecProtocolOptions
ExecProtocolResult
FieldInfo
GlobalListenerHandle
ListenerHandle
NoticeMessage
Oliphaunt
Primary entry point for interacting with the embedded Postgres runtime.
OliphauntBuilder
Builder for opening persistent or temporary Oliphaunt databases.
OliphauntError
Rich error type that mirrors the TypeScript OliphauntError by carrying the original database error along with query context.
OliphauntServer
A supervised local PostgreSQL socket backed by one embedded Oliphaunt runtime.
OliphauntServerBuilder
Builder for OliphauntServer.
PostgresConfig
PostgreSQL startup configuration applied through normal postgres -c GUC handling before the embedded backend starts.
QueryOptions
QueryTemplate
Results
TemplatedQuery
Transaction
Transaction handle used within Oliphaunt::transaction.

Enums§

BackendMessage
DataDirArchiveFormat
Compression format for physical PGDATA archives.
DataTransferContainer
RowMode
Row output mode matching the TypeScript RowMode.

Functions§

format_query
quote_identifier

Type Aliases§

NoticeCallback
ParserMap
Serializer
SerializerMap
TypeParser
Parser function used to convert textual Postgres values into richer Rust values. Mirrors the signature of the TypeScript parser callbacks.