pub struct ClawEngine { /* private fields */ }Expand description
The main entry point for claw-core.
Implementations§
Source§impl ClawEngine
impl ClawEngine
Sourcepub async fn open(config: ClawConfig) -> ClawResult<Self>
pub async fn open(config: ClawConfig) -> ClawResult<Self>
Open (or create) the database at config.db_path.
Sourcepub async fn open_default() -> ClawResult<Self>
pub async fn open_default() -> ClawResult<Self>
Open the database using default ClawConfig.
Sourcepub async fn migrate(&self) -> ClawResult<()>
pub async fn migrate(&self) -> ClawResult<()>
Apply all pending embedded SQL migrations.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Return a reference to the underlying SQLx pool.
Sourcepub fn config(&self) -> &ClawConfig
pub fn config(&self) -> &ClawConfig
Return a reference to the active configuration.
Sourcepub async fn insert_memory(&self, record: &MemoryRecord) -> ClawResult<Uuid>
pub async fn insert_memory(&self, record: &MemoryRecord) -> ClawResult<Uuid>
Insert a new MemoryRecord into the database and cache.
Sourcepub async fn get_memory(&self, id: Uuid) -> ClawResult<MemoryRecord>
pub async fn get_memory(&self, id: Uuid) -> ClawResult<MemoryRecord>
Retrieve a MemoryRecord by id.
Sourcepub async fn update_memory(&self, id: Uuid, content: &str) -> ClawResult<()>
pub async fn update_memory(&self, id: Uuid, content: &str) -> ClawResult<()>
Update memory content and invalidate cache entry.
Sourcepub async fn delete_memory(&self, id: Uuid) -> ClawResult<()>
pub async fn delete_memory(&self, id: Uuid) -> ClawResult<()>
Delete a memory row and invalidate cache entry.
Sourcepub async fn list_memories(
&self,
type_filter: Option<MemoryType>,
) -> ClawResult<Vec<MemoryRecord>>
pub async fn list_memories( &self, type_filter: Option<MemoryType>, ) -> ClawResult<Vec<MemoryRecord>>
List memory rows, optionally filtered by type.
Sourcepub async fn list_memories_paginated(
&self,
type_filter: Option<MemoryType>,
opts: ListOptions,
) -> ClawResult<ListPage<MemoryRecord>>
pub async fn list_memories_paginated( &self, type_filter: Option<MemoryType>, opts: ListOptions, ) -> ClawResult<ListPage<MemoryRecord>>
List memory rows with keyset pagination.
Sourcepub async fn get_memories_by_type(
&self,
memory_type: MemoryType,
opts: Option<ListOptions>,
) -> ClawResult<ListPage<MemoryRecord>>
pub async fn get_memories_by_type( &self, memory_type: MemoryType, opts: Option<ListOptions>, ) -> ClawResult<ListPage<MemoryRecord>>
List memories by type with pagination.
Sourcepub async fn search_by_tag(&self, tag: &str) -> ClawResult<Vec<MemoryRecord>>
pub async fn search_by_tag(&self, tag: &str) -> ClawResult<Vec<MemoryRecord>>
Search by exact tag using indexed lookup.
Sourcepub async fn search_by_tag_paginated(
&self,
tag: &str,
limit: u32,
offset: u32,
) -> ClawResult<Vec<MemoryRecord>>
pub async fn search_by_tag_paginated( &self, tag: &str, limit: u32, offset: u32, ) -> ClawResult<Vec<MemoryRecord>>
Search by exact tag with explicit limit/offset.
Sourcepub async fn fts_search(&self, query: &str) -> ClawResult<Vec<MemoryRecord>>
pub async fn fts_search(&self, query: &str) -> ClawResult<Vec<MemoryRecord>>
Full-text search using SQLite FTS5.
Sourcepub async fn expire_ttl_memories(&self) -> ClawResult<u64>
pub async fn expire_ttl_memories(&self) -> ClawResult<u64>
Expire all memory rows whose TTL has elapsed.
Sourcepub async fn start_session(&self) -> ClawResult<String>
pub async fn start_session(&self) -> ClawResult<String>
Start a new session and return its id.
Sourcepub async fn end_session(&self, session_id: &str) -> ClawResult<()>
pub async fn end_session(&self, session_id: &str) -> ClawResult<()>
Mark a session as ended.
Sourcepub async fn get_session(&self, session_id: &str) -> ClawResult<Session>
pub async fn get_session(&self, session_id: &str) -> ClawResult<Session>
Retrieve a session lifecycle record.
Sourcepub async fn list_sessions(
&self,
opts: Option<ListOptions>,
) -> ClawResult<ListPage<Session>>
pub async fn list_sessions( &self, opts: Option<ListOptions>, ) -> ClawResult<ListPage<Session>>
List sessions with keyset pagination.
Sourcepub async fn record_tool_output(
&self,
output: &ToolOutputRecord,
) -> ClawResult<()>
pub async fn record_tool_output( &self, output: &ToolOutputRecord, ) -> ClawResult<()>
Record a tool-output entry.
Sourcepub async fn list_tool_outputs(
&self,
session_id: &str,
) -> ClawResult<Vec<ToolOutputRecord>>
pub async fn list_tool_outputs( &self, session_id: &str, ) -> ClawResult<Vec<ToolOutputRecord>>
List tool-output rows for a session.
Sourcepub async fn transaction(&self) -> ClawResult<ClawTransaction<'_>>
pub async fn transaction(&self) -> ClawResult<ClawTransaction<'_>>
Begin a new transaction.
Sourcepub async fn begin_transaction(&self) -> ClawResult<ClawTransaction<'_>>
pub async fn begin_transaction(&self) -> ClawResult<ClawTransaction<'_>>
Begin a new transaction (alias of ClawEngine::transaction).
Sourcepub async fn snapshot(&self) -> ClawResult<PathBuf>
pub async fn snapshot(&self) -> ClawResult<PathBuf>
Create an atomic snapshot file under snapshot_dir.
Sourcepub async fn snapshot_create(&self) -> ClawResult<SnapshotMeta>
pub async fn snapshot_create(&self) -> ClawResult<SnapshotMeta>
Backward-compatible snapshot helper that returns rich metadata.
Sourcepub async fn restore(&mut self, snapshot_path: &Path) -> ClawResult<()>
pub async fn restore(&mut self, snapshot_path: &Path) -> ClawResult<()>
Restore the database from a snapshot file.
Sourcepub fn list_snapshots(&self) -> ClawResult<Vec<SnapshotManifest>>
pub fn list_snapshots(&self) -> ClawResult<Vec<SnapshotManifest>>
Return all snapshot manifests sorted newest-first.
Sourcepub fn delete_snapshot(&self, path: &Path) -> ClawResult<()>
pub fn delete_snapshot(&self, path: &Path) -> ClawResult<()>
Delete a snapshot database file and its sidecar manifest.
Sourcepub async fn cache_stats(&self) -> CacheStats
pub async fn cache_stats(&self) -> CacheStats
Return a snapshot of current cache statistics.
Sourcepub async fn stats(&self) -> ClawResult<ClawStats>
pub async fn stats(&self) -> ClawResult<ClawStats>
Return comprehensive runtime statistics.
Sourcepub async fn db_stats(&self) -> ClawResult<DbStats>
pub async fn db_stats(&self) -> ClawResult<DbStats>
Return database-level table counts.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ClawEngine
impl !RefUnwindSafe for ClawEngine
impl Send for ClawEngine
impl Sync for ClawEngine
impl Unpin for ClawEngine
impl UnsafeUnpin for ClawEngine
impl !UnwindSafe for ClawEngine
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
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