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 load_catalogs(&self) -> Result<Vec<(NamespaceId, String)>>
pub fn load_catalogs(&self) -> Result<Vec<(NamespaceId, String)>>
Return all known catalogs with their namespace identifiers and labels.
§Errors
Returns an error if the catalog metadata cannot be read.
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 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 set_channel_namespace(
&self,
channel_name: &str,
namespace_id: NamespaceId,
) -> Result<()>
pub fn set_channel_namespace( &self, channel_name: &str, namespace_id: NamespaceId, ) -> Result<()>
Persist the mapping from a channel name to its catalog namespace.
§Errors
Returns an error if the mapping cannot be stored.
Sourcepub fn get_channel_namespace(
&self,
channel_name: &str,
) -> Result<Option<NamespaceId>>
pub fn get_channel_namespace( &self, channel_name: &str, ) -> Result<Option<NamespaceId>>
Look up the catalog namespace for a channel name.
§Errors
Returns an error if the database cannot be queried.
Sourcepub fn load_channel_namespaces(&self) -> Result<Vec<(String, NamespaceId)>>
pub fn load_channel_namespaces(&self) -> Result<Vec<(String, NamespaceId)>>
Return all channel-to-namespace mappings.
§Errors
Returns an error if the database cannot be queried.
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.
Sourcepub fn save_denylist_rules(&self, rules: &[DenylistRule]) -> Result<()>
pub fn save_denylist_rules(&self, rules: &[DenylistRule]) -> Result<()>
Sourcepub fn load_denylist_rules(&self) -> Result<Vec<DenylistRule>>
pub fn load_denylist_rules(&self) -> Result<Vec<DenylistRule>>
Load persisted denylist rules from the database.
§Errors
Returns an error if the rules cannot be read.
Sourcepub fn load_filter_lists(&self) -> Result<Vec<FilterList>>
pub fn load_filter_lists(&self) -> Result<Vec<FilterList>>
Load persisted filter list subscriptions from the database.
§Errors
Returns an error if the filter lists cannot be read.
Sourcepub fn upsert_filter_list(&self, list: &FilterList) -> Result<()>
pub fn upsert_filter_list(&self, list: &FilterList) -> Result<()>
Sourcepub fn load_links(
&self,
) -> Result<(Vec<MutablePointer>, Vec<String>, Vec<PrivateLink>)>
pub fn load_links( &self, ) -> Result<(Vec<MutablePointer>, Vec<String>, Vec<PrivateLink>)>
Sourcepub fn save_links(
&self,
pointers: &[MutablePointer],
mirrors: &[String],
revoked: &[PrivateLink],
) -> Result<()>
pub fn save_links( &self, pointers: &[MutablePointer], mirrors: &[String], revoked: &[PrivateLink], ) -> Result<()>
Sourcepub fn upsert_link_pointer(&self, pointer: &MutablePointer) -> Result<()>
pub fn upsert_link_pointer(&self, pointer: &MutablePointer) -> Result<()>
Upsert a single mutable pointer to the stable links table.
§Errors
Returns an error if the pointer cannot be persisted.
Trait Implementations§
Source§impl Clone for IndexingDatabase
impl Clone for IndexingDatabase
Auto 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