pub struct AimemDb { /* private fields */ }Expand description
Shared Turso database handle.
Clone is cheap — the underlying Database is Arc-wrapped.
Implementations§
Source§impl AimemDb
impl AimemDb
Sourcepub async fn open(path: impl AsRef<Path>) -> DbResult<Self>
pub async fn open(path: impl AsRef<Path>) -> DbResult<Self>
Open (or create) the AiMem DB at the given path and run schema migrations.
Sourcepub fn conn(&self) -> DbResult<Connection>
pub fn conn(&self) -> DbResult<Connection>
Acquire a write-capable connection from the database.
Kept write-capable for backward compatibility with existing callers.
Sourcepub async fn embedding_dimension(&self) -> DbResult<Option<usize>>
pub async fn embedding_dimension(&self) -> DbResult<Option<usize>>
Return the configured embedding dimension, inferring it from existing stored vectors when upgrading older databases that predate metadata.
pub async fn embedding_profile(&self) -> DbResult<EmbeddingStoreProfile>
Sourcepub async fn assert_embedding_dimension(&self, dim: usize) -> DbResult<()>
pub async fn assert_embedding_dimension(&self, dim: usize) -> DbResult<()>
Validate that a query vector matches the store dimension when known.
pub async fn assert_embedding_profile( &self, dim: usize, provider: &str, model: &str, ) -> DbResult<()>
Sourcepub async fn insert_drawer(
&self,
drawer: &Drawer,
embedding: Option<&[f32]>,
) -> DbResult<bool>
pub async fn insert_drawer( &self, drawer: &Drawer, embedding: Option<&[f32]>, ) -> DbResult<bool>
Insert a drawer. Returns false if the ID already exists (no-op).
Sourcepub async fn insert_drawer_with_profile(
&self,
drawer: &Drawer,
embedding: Option<&[f32]>,
provider: &str,
model: &str,
) -> DbResult<bool>
pub async fn insert_drawer_with_profile( &self, drawer: &Drawer, embedding: Option<&[f32]>, provider: &str, model: &str, ) -> DbResult<bool>
Insert a drawer and validate the embedding profile against store metadata.
Sourcepub async fn drawer_exists(&self, id: &str) -> DbResult<bool>
pub async fn drawer_exists(&self, id: &str) -> DbResult<bool>
Check whether a drawer ID already exists.
Sourcepub async fn source_already_mined(&self, source_file: &str) -> DbResult<bool>
pub async fn source_already_mined(&self, source_file: &str) -> DbResult<bool>
Check if a source file has already been mined.
Sourcepub async fn delete_drawer(&self, id: &str) -> DbResult<bool>
pub async fn delete_drawer(&self, id: &str) -> DbResult<bool>
Delete a drawer by ID.
Sourcepub async fn find_drawers_by_exact_content(
&self,
content: &str,
limit: usize,
) -> DbResult<Vec<Drawer>>
pub async fn find_drawers_by_exact_content( &self, content: &str, limit: usize, ) -> DbResult<Vec<Drawer>>
Find drawers whose content exactly matches the provided text.
Sourcepub async fn drawer_count(&self) -> DbResult<i64>
pub async fn drawer_count(&self) -> DbResult<i64>
Total drawer count.
Sourcepub async fn taxonomy(
&self,
) -> DbResult<(Vec<(String, i64)>, Vec<(String, i64)>)>
pub async fn taxonomy( &self, ) -> DbResult<(Vec<(String, i64)>, Vec<(String, i64)>)>
Return wing → count and room → count aggregates.
Sourcepub async fn fetch_drawers(
&self,
wing: Option<&str>,
room: Option<&str>,
limit: usize,
) -> DbResult<Vec<Drawer>>
pub async fn fetch_drawers( &self, wing: Option<&str>, room: Option<&str>, limit: usize, ) -> DbResult<Vec<Drawer>>
Fetch all drawers in a wing (optionally filtered by room), ordered by filing time desc.
Sourcepub async fn upsert_entity(&self, entity: &Entity) -> DbResult<()>
pub async fn upsert_entity(&self, entity: &Entity) -> DbResult<()>
Insert or replace an entity.
Sourcepub async fn insert_triple(&self, triple: &Triple) -> DbResult<bool>
pub async fn insert_triple(&self, triple: &Triple) -> DbResult<bool>
Insert a triple (ignore if already exists).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AimemDb
impl !RefUnwindSafe for AimemDb
impl !UnwindSafe for AimemDb
impl Send for AimemDb
impl Sync for AimemDb
impl Unpin for AimemDb
impl UnsafeUnpin for AimemDb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more