Skip to main content

Db

Struct Db 

Source
pub struct Db { /* private fields */ }

Implementations§

Source§

impl Db

Source

pub fn open() -> Result<Self>

Source

pub fn open_read_only() -> Result<Self>

Source

pub fn open_path(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn open_read_only_path(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn migrate(&self) -> Result<()>

Source

pub fn record_message(&self, record: MessageRecord<'_>) -> Result<i64>

Source

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>

Source

pub fn record_crash( &self, ts_utc: DateTime<Utc>, kind: &str, agent: &str, detail_json: &str, ) -> Result<i64>

Source

pub fn record_tick( &self, ts_utc: DateTime<Utc>, source: &str, detail_json: &str, ) -> Result<i64>

Source

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>

Source

pub fn record_session( &self, ts_utc: DateTime<Utc>, agent: &str, session_num: i64, event: SessionEvent, ) -> Result<i64>

Source

pub fn record_clone_dispatch( &self, record: CloneDispatchRecord<'_>, ) -> Result<i64>

Source

pub fn record_harvest_event( &self, record: HarvestEventRecord<'_>, ) -> Result<i64>

Source

pub fn record_communication_event( &self, record: CommunicationEventRecord<'_>, ) -> Result<i64>

Source

pub fn list_communication_events(&self) -> Result<Vec<CommunicationEvent>>

Source

pub fn record_mcp_tool_call(&self, record: McpToolCallRecord<'_>) -> Result<i64>

Source

pub fn record_git_operation( &self, record: GitOperationRecord<'_>, ) -> Result<i64>

Source

pub fn record_owner_directive( &self, record: OwnerDirectiveRecord<'_>, ) -> Result<i64>

Source

pub fn record_token_usage(&self, record: TokenUsageRecord<'_>) -> Result<i64>

Source

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.

Source

pub fn record_source_error(&self, record: SourceErrorRecord<'_>) -> Result<i64>

Source

pub fn record_iroh_event(&self, record: IrohEventRecord<'_>) -> Result<i64>

Source

pub fn record_watchdog_event( &self, record: WatchdogEventRecord<'_>, ) -> Result<i64>

Source

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).

Source

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.

Source

pub fn reset_source_cursor(&self, source: &str) -> Result<bool>

Delete the cursor row for this source. Idempotent; returns whether a row was removed.

Source

pub fn list_source_cursors(&self) -> Result<Vec<SourceCursorRow>>

Source

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.

Source

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.

Source

pub fn tail_events(&self, source: &str, limit: i64) -> Result<Vec<EventRow>>

Tail the most recent events for a source (newest first).

Source

pub fn record_task(&self, record: TaskRecord<'_>) -> Result<i64>

Source

pub fn update_task(&self, update: TaskUpdate<'_>) -> Result<TaskRow>

Source

pub fn get_task(&self, id: i64) -> Result<Option<TaskRow>>

Source

pub fn list_tasks( &self, status: Option<&str>, priority: Option<&str>, ) -> Result<Vec<TaskRow>>

Source

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

Source

pub fn query_batches(&self, sql: &str) -> Result<Vec<RecordBatch>>

Source

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,