Developer beta 0.1.0-beta.1 documentation. The build is not available for download yet; these pages describe the beta as built and tested on Linux x86-64.

Rust SDK

The crate holadb-client provides a low-level protocol Client and a higher-level holadb_client::sdk module.

use holadb_client::sdk::{Database, Value};

let mut db = Database::connect("holadb://app:secret@127.0.0.1:7433")?;
db.execute("CREATE TABLE IF NOT EXISTS users (id BIGINT PRIMARY KEY, name TEXT NOT NULL)", &[])?;
db.execute("INSERT INTO users VALUES ($1, $2)", &[1i64.into(), "Ann".into()])?;

let rows = db.query("SELECT id, name FROM users WHERE id = $1", &[1i64.into()])?;
for row in &rows.rows {
    let name: &Value = &row[1];
    println!("{name:?}");
}

// transactions: the guard rolls back if dropped without commit
let mut tx = db.transaction()?;
tx.execute("UPDATE users SET name = $1 WHERE id = $2", &["Ann K".into(), 1i64.into()])?;
tx.commit()?;

// prepared statements and cursors
let p = db.prepare("SELECT name FROM users WHERE id = $1")?;
let r = db.query_prepared(&p, &[1i64.into()])?;
let mut cur = db.cursor("SELECT * FROM users ORDER BY id", &[], 1000)?;
while let Some(page) = cur.next_page()? { /* … */ }

// typed access
let mut users = db.table("users");
let n: u64 = users.count()?;
db.close()?;
  • Value is the wire value: Null, Bool, Int, UInt, Float, Text, Bytes, Timestamp (µs since the epoch), Json (text). From conversions exist for the usual Rust types.
  • Database::connect("holadb://user:password@host:port") authenticates with SCRAM-SHA-256 before returning; authenticate(user, password) does it on an open connection; raw().whoami() reports the identity. A user without a password in the URL takes it from HOLADB_PASSWORD.
  • TLS: holadbs://host:port?ca=/path/ca.pem&servername=name (or Client::connect_tls(addr, &TlsOptions { server_name, ca_pem })). The server certificate chain and host name are always verified (against the CA file, else the Mozilla roots); there is no insecure mode and no fallback to plaintext. Over TLS the login is SCRAM-SHA-256-PLUS with tls-server-end-point channel binding; is_tls() tells.
  • Errors: holadb_client::sdk::Error wraps the server error code (ErrorCode::Sql, Constraint, Transaction, Cursor, NoSuchTable, Unauthorized, Forbidden, AuthFailed, …).
  • The low-level Client (db.raw()) also exposes engine-level operations (statistics, verification, checkpoints) which need the admin role once users exist.

The crate has no dependencies beyond the workspace crates and sha2 (for SCRAM).