pub struct IndexingDatabase { /* private fields */ }Expand description
Thread-safe SQLite database used by the indexing service.
Implementations§
Source§impl IndexingDatabase
impl IndexingDatabase
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open or create an indexing database.
§Errors
Returns an error if the database cannot be opened or initialized.
Sourcepub fn in_memory() -> Result<Self>
pub fn in_memory() -> Result<Self>
Create an isolated in-memory indexing database.
§Errors
Returns an error if SQLite cannot initialize the schema.
pub fn path(&self) -> &Path
Sourcepub fn schema_version(&self) -> Result<String>
pub fn schema_version(&self) -> Result<String>
Return the persisted indexing schema version.
§Errors
Returns an error if the schema metadata cannot be read.
Sourcepub fn has_fts5(&self) -> Result<bool>
pub fn has_fts5(&self) -> Result<bool>
Return whether the SQLite FTS5 virtual table is available.
§Errors
Returns an error if the schema cannot be queried.
Sourcepub fn schema_objects(&self) -> Result<Vec<String>>
pub fn schema_objects(&self) -> Result<Vec<String>>
Return the names of schema objects owned by the index.
§Errors
Returns an error if SQLite cannot query its schema.
Sourcepub fn has_table(&self, name: &str) -> Result<bool>
pub fn has_table(&self, name: &str) -> Result<bool>
Return whether a schema table or view exists.
§Errors
Returns an error if SQLite cannot query its schema.
Sourcepub fn folder_count(&self) -> Result<usize>
pub fn folder_count(&self) -> Result<usize>
Return the number of opted-in folders.
§Errors
Returns an error if SQLite cannot query the database.
Sourcepub fn entry_count(&self) -> Result<usize>
pub fn entry_count(&self) -> Result<usize>
Sourcepub fn is_folder_enabled(&self, namespace_id: NamespaceId) -> Result<bool>
pub fn is_folder_enabled(&self, namespace_id: NamespaceId) -> Result<bool>
Return whether a namespace is currently opted into indexing.
§Errors
Returns an error if SQLite cannot query the database.
Sourcepub fn upsert_entry(
&self,
namespace_id: NamespaceId,
key: impl AsRef<[u8]>,
hash: Hash,
size: u64,
) -> Result<IndexedEntry>
pub fn upsert_entry( &self, namespace_id: NamespaceId, key: impl AsRef<[u8]>, hash: Hash, size: u64, ) -> Result<IndexedEntry>
Insert or update an entry in the index.
§Errors
Returns an error if the database cannot persist the entry.
Sourcepub fn remove_entry(
&self,
namespace_id: NamespaceId,
key: impl AsRef<[u8]>,
) -> Result<bool>
pub fn remove_entry( &self, namespace_id: NamespaceId, key: impl AsRef<[u8]>, ) -> Result<bool>
Remove an indexed entry if it exists.
§Errors
Returns an error if the database cannot remove the entry.
Sourcepub fn search(&self, query: &str, limit: usize) -> Result<Vec<IndexedEntry>>
pub fn search(&self, query: &str, limit: usize) -> Result<Vec<IndexedEntry>>
Search indexed paths and metadata using SQLite FTS5.
An empty query returns the most recently updated entries. FTS5 query syntax is passed through for non-empty queries.
§Errors
Returns an error if the query is invalid or SQLite cannot read results.
Sourcepub fn enable_catalog(
&self,
namespace_id: NamespaceId,
label: &str,
) -> Result<()>
pub fn enable_catalog( &self, namespace_id: NamespaceId, label: &str, ) -> Result<()>
Register a catalog that is published or subscribed to locally.
§Errors
Returns an error if the catalog metadata cannot be stored.
Sourcepub fn catalog_count(&self) -> Result<usize>
pub fn catalog_count(&self) -> Result<usize>
Sourcepub fn catalog_entry_count(&self) -> Result<usize>
pub fn catalog_entry_count(&self) -> Result<usize>
Return the number of records imported from catalogs.
§Errors
Returns an error if SQLite cannot query the database.
Sourcepub fn upsert_catalog_record(
&self,
record: &CatalogRecord,
) -> Result<CatalogRecord>
pub fn upsert_catalog_record( &self, record: &CatalogRecord, ) -> Result<CatalogRecord>
Insert or update a record received from a catalog.
§Errors
Returns an error if the catalog is not registered or the record cannot be persisted.
Sourcepub fn search_catalogs(
&self,
query: &str,
limit: usize,
) -> Result<Vec<CatalogRecord>>
pub fn search_catalogs( &self, query: &str, limit: usize, ) -> Result<Vec<CatalogRecord>>
Search all subscribed catalogs with SQLite FTS5.
An empty query returns the most recently updated catalog records.
§Errors
Returns an error if the query is invalid or SQLite cannot read results.
Sourcepub fn global_search(
&self,
query: &str,
limit: usize,
) -> Result<Vec<CatalogRecord>>
pub fn global_search( &self, query: &str, limit: usize, ) -> Result<Vec<CatalogRecord>>
Search all known catalogs. This is an alias for Self::search_catalogs.
§Errors
Returns an error if the query is invalid or SQLite cannot read results.
Sourcepub fn catalog_search(
&self,
query: &str,
limit: usize,
) -> Result<Vec<CatalogRecord>>
pub fn catalog_search( &self, query: &str, limit: usize, ) -> Result<Vec<CatalogRecord>>
Search all known catalogs. Alias for Self::search_catalogs.
§Errors
Returns an error if the query is invalid or SQLite cannot read results.
Sourcepub fn append_wot_metadata(&self, entry: &MetadataEntry) -> Result<bool>
pub fn append_wot_metadata(&self, entry: &MetadataEntry) -> Result<bool>
Append a signed Web-of-Trust metadata entry to the local index.
§Errors
Returns an error if the entry is invalid or SQLite cannot persist it.
Sourcepub fn search_wot_metadata(
&self,
query: &str,
limit: usize,
) -> Result<Vec<MetadataEntry>>
pub fn search_wot_metadata( &self, query: &str, limit: usize, ) -> Result<Vec<MetadataEntry>>
Search accepted Web-of-Trust metadata using SQLite FTS5.
§Errors
Returns an error if the query is invalid or metadata cannot be read.
Sourcepub fn disable_catalog(&self, namespace_id: NamespaceId) -> Result<()>
pub fn disable_catalog(&self, namespace_id: NamespaceId) -> Result<()>
Remove a catalog and all records imported from it.
§Errors
Returns an error if the catalog cannot be removed.
Sourcepub fn enable_folder(
&self,
namespace_id: NamespaceId,
label: &str,
) -> Result<()>
pub fn enable_folder( &self, namespace_id: NamespaceId, label: &str, ) -> Result<()>
Register a namespace for local indexing.
§Errors
Returns an error if the folder metadata cannot be stored.
Sourcepub fn disable_folder(&self, namespace_id: NamespaceId) -> Result<()>
pub fn disable_folder(&self, namespace_id: NamespaceId) -> Result<()>
Remove a namespace and its indexed entries.
§Errors
Returns an error if the folder metadata or entries cannot be removed.
Trait Implementations§
Source§impl Clone for IndexingDatabase
impl Clone for IndexingDatabase
Source§fn clone(&self) -> IndexingDatabase
fn clone(&self) -> IndexingDatabase
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for IndexingDatabase
impl RefUnwindSafe for IndexingDatabase
impl Send for IndexingDatabase
impl Sync for IndexingDatabase
impl Unpin for IndexingDatabase
impl UnsafeUnpin for IndexingDatabase
impl UnwindSafe for IndexingDatabase
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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