Recall Quickstart for Rust
Recall's core is Rust. Using it from Rust is the most direct path. Async on tokio; requires Rust 1.78+.
Add the crate
bash
cargo add arc-labs-recall
# or in Cargo.toml:
# [dependencies]
# arc-labs-recall = "0.1"
# tokio = { version = "1", features = ["full"] }Initialize
rust
use arc_labs_recall::{Recall, StoreConfig};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let recall = Recall::builder()
.store(StoreConfig::Sqlite { path: "./recall.db".into() })
// For production:
// .store(StoreConfig::Postgres { url: env::var("DATABASE_URL")? })
.build()
.await?;
Ok(())
}Write a memory
rust
use arc_labs_recall::{Scope, Source, Turn};
recall.write()
.scope(Scope::for_user("u_alice"))
.source(Source::Turn(Turn {
user: "I prefer dark mode in my IDE — light themes hurt my eyes.".into(),
assistant: "Noted — I'll default to dark mode for editor recommendations.".into(),
}))
.send()
.await?;
// The 7-stage pipeline runs.
// Result: 1 preference stored ("user prefers dark mode in IDE", confidence 0.93)Retrieve
rust
let results = recall.search()
.scope(Scope::for_user("u_alice"))
.query("what theme should I use?")
.limit(10)
.send()
.await?;
println!("{:#?}", results.first());
// Some(Memory {
// id: "mem_01H...",
// ty: MemoryType::Preference,
// content: "user prefers dark mode in IDE",
// confidence: 0.93,
// score: 0.91,
// freshness: 1.0,
// })Render into a prompt
rust
let ctx = recall.context()
.scope(Scope::for_user("u_alice"))
.query(&user_message)
.budget(1500) // tokens
.send()
.await?;
let system_prompt = format!(
"You have these memories about the user:\n{}",
ctx.render_structured()
);Errors are typed
Recall uses a single RecallError enum at the public boundary. thiserror-based; play nicely with anyhow if that's your style.
rust
use arc_labs_recall::{Recall, RecallError};
match recall.search().query("...").send().await {
Ok(results) => { /* ... */ }
Err(RecallError::Timeout(elapsed)) => {
tracing::warn!(?elapsed, "search timed out");
}
Err(RecallError::StoreUnavailable) => {
// circuit-break
}
Err(e) => return Err(e.into()),
}Done.
You have a working memory layer in Rust. Continue with the docs for production patterns, or browse the Learn track for architecture deep-dives.