Rust SDK
aurabase crate — typed async client for Tokio/axum/actix.
Cargo#
toml
[dependencies]
aurabase = "0.1"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
Attention
Breaking changes are announced in the changelog with a period of 30 days before release.
Default client#
rust
use aurabase::AuraClient;
use std::env;
pub fn client() -> AuraClient {
AuraClient::new(
&env::var("NEXT_PUBLIC_AURABASE_URL").expect("NEXT_PUBLIC_AURABASE_URL"),
&env::var("AURABASE_SERVICE_ROLE_KEY").expect("AURABASE_SERVICE_ROLE_KEY"),
None, // AuraClientOptions (auth store)
)
}
Typed select#
The row type is given to from::<Row>(); order(column, direction) takes the direction as a second argument; execute() returns an AuraResponse whose data is the list of rows. Like the JavaScript SDK, an HTTP error is reported in AuraResponse.error, not as Err: call into_result()? to turn it into an Err, otherwise unwrap_or_default() on data hides a rejected key behind an empty list.
rust
use aurabase::{AuraClient, AuraError};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct Todo {
pub id: i64,
pub title: String,
pub done: bool,
}
pub async fn recent(aura: &AuraClient) -> Result<Vec<Todo>, AuraError> {
let res = aura
.from::<Todo>("todos")
.select("id,title,done")
.order("created_at", "desc")
.limit(5)
.execute()
.await?
.into_result()?; // an HTTP error (invalid key, RLS, missing table…) becomes `Err`
Ok(res.unwrap_or_default())
}
aura db generate --lang rust#
bash
# Generates Deserialize/Serialize structs and enums from your project schema
aura db generate --lang rust > src/aurabase_types.rs
API still evolving#
These surfaces are still subject to change. Conditional compilation behind the unstable feature in Cargo.toml.
aura.channel()— WebSocket/SSE clientaura.functions.invoke()— edge function callaura.storage.upload_resumable()— tus-style chunks