Skip to main content

ClawEngine

Struct ClawEngine 

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

The main entry point for claw-core.

Implementations§

Source§

impl ClawEngine

Source

pub async fn open(config: ClawConfig) -> ClawResult<Self>

Open (or create) the database at config.db_path.

Source

pub async fn open_default() -> ClawResult<Self>

Open the database using default ClawConfig.

Source

pub async fn migrate(&self) -> ClawResult<()>

Apply all pending embedded SQL migrations.

Source

pub fn pool(&self) -> &SqlitePool

Return a reference to the underlying SQLx pool.

Source

pub fn config(&self) -> &ClawConfig

Return a reference to the active configuration.

Source

pub async fn close(self)

Close the connection pool, waiting for in-flight queries to complete.

Source

pub async fn insert_memory(&self, record: &MemoryRecord) -> ClawResult<Uuid>

Insert a new MemoryRecord into the database and cache.

Source

pub async fn get_memory(&self, id: Uuid) -> ClawResult<MemoryRecord>

Retrieve a MemoryRecord by id.

Source

pub async fn update_memory(&self, id: Uuid, content: &str) -> ClawResult<()>

Update memory content and invalidate cache entry.

Source

pub async fn delete_memory(&self, id: Uuid) -> ClawResult<()>

Delete a memory row and invalidate cache entry.

Source

pub async fn list_memories( &self, type_filter: Option<MemoryType>, ) -> ClawResult<Vec<MemoryRecord>>

List memory rows, optionally filtered by type.

Source

pub async fn list_memories_paginated( &self, type_filter: Option<MemoryType>, opts: ListOptions, ) -> ClawResult<ListPage<MemoryRecord>>

List memory rows with keyset pagination.

Source

pub async fn get_memories_by_type( &self, memory_type: MemoryType, opts: Option<ListOptions>, ) -> ClawResult<ListPage<MemoryRecord>>

List memories by type with pagination.

Source

pub async fn search_by_tag(&self, tag: &str) -> ClawResult<Vec<MemoryRecord>>

Search by exact tag using indexed lookup.

Source

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.

Full-text search using SQLite FTS5.

Source

pub async fn expire_ttl_memories(&self) -> ClawResult<u64>

Expire all memory rows whose TTL has elapsed.

Source

pub async fn start_session(&self) -> ClawResult<String>

Start a new session and return its id.

Source

pub async fn end_session(&self, session_id: &str) -> ClawResult<()>

Mark a session as ended.

Source

pub async fn get_session(&self, session_id: &str) -> ClawResult<Session>

Retrieve a session lifecycle record.

Source

pub async fn list_sessions( &self, opts: Option<ListOptions>, ) -> ClawResult<ListPage<Session>>

List sessions with keyset pagination.

Source

pub async fn record_tool_output( &self, output: &ToolOutputRecord, ) -> ClawResult<()>

Record a tool-output entry.

Source

pub async fn list_tool_outputs( &self, session_id: &str, ) -> ClawResult<Vec<ToolOutputRecord>>

List tool-output rows for a session.

Source

pub async fn transaction(&self) -> ClawResult<ClawTransaction<'_>>

Begin a new transaction.

Source

pub async fn begin_transaction(&self) -> ClawResult<ClawTransaction<'_>>

Begin a new transaction (alias of ClawEngine::transaction).

Source

pub async fn snapshot(&self) -> ClawResult<PathBuf>

Create an atomic snapshot file under snapshot_dir.

Source

pub async fn snapshot_create(&self) -> ClawResult<SnapshotMeta>

Backward-compatible snapshot helper that returns rich metadata.

Source

pub async fn restore(&mut self, snapshot_path: &Path) -> ClawResult<()>

Restore the database from a snapshot file.

Source

pub fn list_snapshots(&self) -> ClawResult<Vec<SnapshotManifest>>

Return all snapshot manifests sorted newest-first.

Source

pub fn delete_snapshot(&self, path: &Path) -> ClawResult<()>

Delete a snapshot database file and its sidecar manifest.

Source

pub async fn cache_stats(&self) -> CacheStats

Return a snapshot of current cache statistics.

Source

pub async fn stats(&self) -> ClawResult<ClawStats>

Return comprehensive runtime statistics.

Source

pub async fn db_stats(&self) -> ClawResult<DbStats>

Return database-level table counts.

Trait Implementations§

Source§

impl Debug for ClawEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more