Skip to main content

SqliteStore

Struct SqliteStore 

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

SQLite-backed storage for the Bitcoin Knowledge Base.

Uses rusqlite with bundled FTS5 for full-text search. All database access is serialized through a Mutex<Connection>.

Implementations§

Source§

impl SqliteStore

Source

pub fn open(path: &Path) -> Result<Self>

Open (or create) a database at the given path and run migrations.

Source

pub fn open_in_memory() -> Result<Self>

Create an in-memory database (for tests).

Source

pub async fn upsert_document(&self, doc: &Document) -> Result<()>

Insert or update a document, appending to the change log.

Source

pub async fn insert_reference(&self, reference: &Reference) -> Result<()>

Insert a cross-reference.

Source

pub async fn delete_refs_from(&self, doc_id: &str) -> Result<()>

Delete all references originating from a document (for re-enrichment).

Source

pub async fn upsert_concept_mention( &self, doc_id: &str, concept_slug: &str, confidence: f32, ) -> Result<()>

Insert or replace a concept mention for a document.

Source

pub async fn delete_concept_mentions(&self, doc_id: &str) -> Result<()>

Delete all concept mentions for a document (for re-enrichment).

Source

pub async fn reset_source_type( &self, source_type: &str, sync_id_patterns: &[String], ) -> Result<u64>

Delete all documents, refs, concept mentions, and sync state for a given source type. Returns the number of documents deleted.

Source

pub async fn docs_for_reenrich( &self, source_type: &str, ) -> Result<Vec<(String, Option<String>, Option<String>)>>

Return all document IDs and bodies for a given source type, for re-enrichment. Streams in batches to avoid loading everything into memory at once.

Source

pub async fn get_stats(&self) -> Result<Vec<(String, i64)>>

Get document counts grouped by source type.

Source

pub async fn get_all_sync_states(&self) -> Result<Vec<SyncState>>

Get all sync states.

Source

pub async fn compact_change_log(&self, max_age: Duration) -> Result<u64>

Compact the change log by deleting entries older than the given duration.

Source

pub async fn get_sync_state(&self, source_id: &str) -> Result<Option<SyncState>>

Get or create sync state for a source.

Source

pub async fn update_sync_state(&self, state: &SyncState) -> Result<()>

Update sync state after a sync cycle.

Trait Implementations§

Source§

impl KnowledgeStore for SqliteStore

Source§

fn search<'life0, 'async_trait>( &'life0 self, params: SearchParams, ) -> Pin<Box<dyn Future<Output = Result<SearchResults>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Full-text (and optionally semantic) search across all documents.
Source§

fn get_document<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<DocumentContext>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a single document by ID with full content, references, and concepts.
Source§

fn get_references<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, entity: &'life1 str, ref_type: Option<&'life2 str>, limit: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<Reference>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Find all documents referencing a given entity (BIP, BOLT, issue, commit, or concept).
Source§

fn lookup_bip<'life0, 'async_trait>( &'life0 self, number: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<DocumentContext>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get comprehensive context for a BIP: spec text, all referencing documents, and incoming refs.
Source§

fn lookup_bolt<'life0, 'async_trait>( &'life0 self, number: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<DocumentContext>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get comprehensive context for a BOLT: spec text, all referencing documents, and incoming refs.
Source§

fn lookup_blip<'life0, 'async_trait>( &'life0 self, number: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<DocumentContext>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get comprehensive context for a bLIP: spec text, all referencing documents, and incoming refs.
Source§

fn lookup_lud<'life0, 'async_trait>( &'life0 self, number: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<DocumentContext>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get comprehensive context for a LUD: spec text, all referencing documents, and incoming refs.
Source§

fn lookup_nut<'life0, 'async_trait>( &'life0 self, number: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<DocumentContext>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get comprehensive context for a NUT: spec text, all referencing documents, and incoming refs.
Source§

fn timeline<'life0, 'life1, 'async_trait>( &'life0 self, concept: &'life1 str, after: Option<DateTime<Utc>>, before: Option<DateTime<Utc>>, ) -> Pin<Box<dyn Future<Output = Result<Timeline>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Chronological timeline of a concept across all sources.
Source§

fn find_commit<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, query: &'life1 str, repo: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<CommitContext>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Find commits matching a query, with associated PR and discussion context.

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, 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