Skip to main content

AgentDB

Struct AgentDB 

Source
pub struct AgentDB { /* private fields */ }
Expand description

The main AgentDB connection — your single-file AI database.

Implementations§

Source§

impl AgentDB

Source

pub fn open(path: &str) -> Result<Self>

Open or create an AgentDB database. Use ":memory:" for tests.

Source

pub fn vectors(&self) -> VectorStore

Access the vector store layer

Source

pub fn memory(&self) -> MemoryGraph

Access the memory graph layer

Source

pub fn fts(&self) -> FullTextStore

Access the full-text search layer

Source

pub fn conversations(&self) -> ConversationStore

Access the conversation / message-threading layer

Source

pub fn workflows(&self) -> WorkflowStore

Access the workflow persistence layer

Source

pub fn traces(&self) -> TraceStore

Access the reasoning-trace layer

Source

pub fn hybrid_query(&self, q: HybridQuery<'_>) -> Result<Vec<HybridResult>>

Run a hybrid graph + vector query

Source

pub fn execute(&self, sql: &str) -> Result<usize>

Execute a raw SQL statement

Source

pub fn execute_params(&self, sql: &str, params: &[&dyn ToSql]) -> Result<usize>

Execute a parameterized SQL statement

Source

pub fn transaction<F, T>(&self, f: F) -> Result<T>
where F: FnOnce(&Transaction<'_>) -> Result<T>,

Run multiple operations atomically inside a single SQLite transaction.

The closure receives a rusqlite::Transaction and may perform any number of reads or writes. If the closure returns Ok, the transaction is committed; if it returns Err (or panics), the transaction is rolled back automatically.

§Example
let db = AgentDB::open(":memory:").unwrap();
db.transaction(|tx| {
    tx.execute("INSERT INTO _adb_nodes (id, label, data) VALUES ('x','tag','{}')", [])?;
    tx.execute("INSERT INTO _adb_nodes (id, label, data) VALUES ('y','tag','{}')", [])?;
    Ok(())
}).unwrap();
Source

pub fn execute_batch(&self, sql: &str) -> Result<()>

Execute one or more semicolon-separated SQL statements as a single atomic batch. This is a convenience wrapper around execute_batch that wraps the statements in an explicit transaction so partial execution is never visible to other threads.

§Example
let db = AgentDB::open(":memory:").unwrap();
db.execute_batch(
    "INSERT INTO _adb_nodes (id,label,data) VALUES ('a','t','{}');
     INSERT INTO _adb_nodes (id,label,data) VALUES ('b','t','{}');"
).unwrap();
Source

pub fn query_json(&self, sql: &str) -> Result<Vec<Value>>

Query and return rows as JSON values

Source

pub fn close(self) -> Result<()>

Flush dirty HNSW indexes and close gracefully

Source

pub fn stats(&self) -> Result<DbStats>

Return database-wide statistics

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V