pub struct Db { /* private fields */ }Implementations§
Source§impl Db
impl Db
pub fn open() -> Result<Self>
pub fn open_read_only() -> Result<Self>
pub fn open_path(path: impl AsRef<Path>) -> Result<Self>
pub fn open_read_only_path(path: impl AsRef<Path>) -> Result<Self>
pub fn migrate(&self) -> Result<()>
pub fn record_message(&self, record: MessageRecord<'_>) -> Result<i64>
pub fn record_cli( &self, ts_utc: DateTime<Utc>, bin: &str, argv_json: &str, exit_code: Option<i64>, duration_ms: Option<i64>, host: &str, ) -> Result<i64>
pub fn record_crash( &self, ts_utc: DateTime<Utc>, kind: &str, agent: &str, detail_json: &str, ) -> Result<i64>
pub fn record_tick( &self, ts_utc: DateTime<Utc>, source: &str, detail_json: &str, ) -> Result<i64>
pub fn record_workspace( &self, ts_utc_created: DateTime<Utc>, name: &str, branch: &str, ts_utc_deleted: Option<DateTime<Utc>>, verdict: Option<&str>, ) -> Result<i64>
pub fn record_session( &self, ts_utc: DateTime<Utc>, agent: &str, session_num: i64, event: SessionEvent, ) -> Result<i64>
pub fn record_clone_dispatch( &self, record: CloneDispatchRecord<'_>, ) -> Result<i64>
pub fn record_harvest_event( &self, record: HarvestEventRecord<'_>, ) -> Result<i64>
pub fn record_communication_event( &self, record: CommunicationEventRecord<'_>, ) -> Result<i64>
pub fn list_communication_events(&self) -> Result<Vec<CommunicationEvent>>
pub fn record_mcp_tool_call(&self, record: McpToolCallRecord<'_>) -> Result<i64>
pub fn record_git_operation( &self, record: GitOperationRecord<'_>, ) -> Result<i64>
pub fn record_owner_directive( &self, record: OwnerDirectiveRecord<'_>, ) -> Result<i64>
pub fn record_token_usage(&self, record: TokenUsageRecord<'_>) -> Result<i64>
Sourcepub fn record_token_usage_batch<'a, I>(&self, records: I) -> Result<usize>where
I: IntoIterator<Item = TokenUsageRecord<'a>>,
pub fn record_token_usage_batch<'a, I>(&self, records: I) -> Result<usize>where
I: IntoIterator<Item = TokenUsageRecord<'a>>,
Batch-insert token usage rows. One turso connection, one transaction,
one bulk id allocation. Use this from ingest paths that emit
thousands of rows; per-row [record_token_usage] opens a fresh
turso connection per call which is dominated by setup cost.
Returns the number of rows written. Empty input is a no-op.
pub fn record_source_error(&self, record: SourceErrorRecord<'_>) -> Result<i64>
pub fn record_iroh_event(&self, record: IrohEventRecord<'_>) -> Result<i64>
pub fn record_watchdog_event( &self, record: WatchdogEventRecord<'_>, ) -> Result<i64>
Sourcepub fn read_source_cursor(&self, source: &str) -> Result<Option<String>>
pub fn read_source_cursor(&self, source: &str) -> Result<Option<String>>
Read the cursor recorded for this source. None means no cursor
has been written yet (first-run).
Sourcepub fn update_source_cursor(&self, source: &str, value: &str) -> Result<()>
pub fn update_source_cursor(&self, source: &str, value: &str) -> Result<()>
Write (upsert) the cursor for this source. updated_at is set
to the current UTC instant.
Sourcepub fn reset_source_cursor(&self, source: &str) -> Result<bool>
pub fn reset_source_cursor(&self, source: &str) -> Result<bool>
Delete the cursor row for this source. Idempotent; returns whether a row was removed.
pub fn list_source_cursors(&self) -> Result<Vec<SourceCursorRow>>
Sourcepub fn insert_event(
&self,
source: &str,
ts_utc: DateTime<Utc>,
payload_json: &str,
) -> Result<i64>
pub fn insert_event( &self, source: &str, ts_utc: DateTime<Utc>, payload_json: &str, ) -> Result<i64>
Insert an event row with delivery_status = 'pending'. Returns
the allocated id so the caller can update the status after the
delivery adapter runs.
Sourcepub fn update_event_delivery(
&self,
id: i64,
status: EventStatus,
reason: Option<&str>,
) -> Result<()>
pub fn update_event_delivery( &self, id: i64, status: EventStatus, reason: Option<&str>, ) -> Result<()>
Transition an event to delivered or failed. reason is the
failure text for failed; ignored (but recorded) for delivered.
Sourcepub fn tail_events(&self, source: &str, limit: i64) -> Result<Vec<EventRow>>
pub fn tail_events(&self, source: &str, limit: i64) -> Result<Vec<EventRow>>
Tail the most recent events for a source (newest first).
pub fn record_task(&self, record: TaskRecord<'_>) -> Result<i64>
pub fn update_task(&self, update: TaskUpdate<'_>) -> Result<TaskRow>
pub fn get_task(&self, id: i64) -> Result<Option<TaskRow>>
pub fn list_tasks( &self, status: Option<&str>, priority: Option<&str>, ) -> Result<Vec<TaskRow>>
pub fn query(&self, sql: &str) -> Result<String>
pub fn query_batches(&self, sql: &str) -> Result<Vec<RecordBatch>>
pub fn schema_version(&self) -> Result<i64>
Auto Trait Implementations§
impl Freeze for Db
impl RefUnwindSafe for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
impl UnwindSafe for Db
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