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 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.
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.
Sourcepub fn upsert_link_mirror(&self, ticket: &str) -> Result<()>
pub fn upsert_link_mirror(&self, ticket: &str) -> Result<()>
Sourcepub fn save_leases(&self, leases: &[ProviderLease]) -> Result<()>
pub fn save_leases(&self, leases: &[ProviderLease]) -> Result<()>
Sourcepub fn load_leases(&self) -> Result<Vec<ProviderLease>>
pub fn load_leases(&self) -> Result<Vec<ProviderLease>>
Sourcepub fn save_trust_delegations(
&self,
delegations: &[TrustDelegation],
) -> Result<()>
pub fn save_trust_delegations( &self, delegations: &[TrustDelegation], ) -> Result<()>
Save trust delegations to the database.
§Errors
Returns an error if the delegations cannot be persisted.
Sourcepub fn load_trust_delegations(&self) -> Result<Vec<TrustDelegation>>
pub fn load_trust_delegations(&self) -> Result<Vec<TrustDelegation>>
Load trust delegations from the database.
§Errors
Returns an error if the delegations cannot be read.
Sourcepub fn save_moderation_records(
&self,
records: &[ModerationRecord],
) -> Result<()>
pub fn save_moderation_records( &self, records: &[ModerationRecord], ) -> Result<()>
Save moderation records to the database.
§Errors
Returns an error if the records cannot be persisted.
Sourcepub fn load_moderation_records(&self) -> Result<Vec<ModerationRecord>>
pub fn load_moderation_records(&self) -> Result<Vec<ModerationRecord>>
Sourcepub fn save_attestations(&self, attestations: &[Attestation]) -> Result<()>
pub fn save_attestations(&self, attestations: &[Attestation]) -> Result<()>
Save attestations to the database.
§Errors
Returns an error if the attestations cannot be persisted.
Sourcepub fn load_attestations(&self) -> Result<Vec<Attestation>>
pub fn load_attestations(&self) -> Result<Vec<Attestation>>
Sourcepub fn save_content_reports(&self, reports: &[ReportRecord]) -> Result<()>
pub fn save_content_reports(&self, reports: &[ReportRecord]) -> Result<()>
Sourcepub fn load_content_reports(&self) -> Result<Vec<ReportRecord>>
pub fn load_content_reports(&self) -> Result<Vec<ReportRecord>>
Sourcepub fn save_provider_bans(&self, bans: &[BanRecord]) -> Result<()>
pub fn save_provider_bans(&self, bans: &[BanRecord]) -> Result<()>
Sourcepub fn load_provider_bans(&self) -> Result<Vec<BanRecord>>
pub fn load_provider_bans(&self) -> Result<Vec<BanRecord>>
Sourcepub fn insert_provider_lease(&self, lease: &ProviderLease) -> Result<()>
pub fn insert_provider_lease(&self, lease: &ProviderLease) -> Result<()>
Insert or replace a single provider lease.
§Errors
Returns an error if the lease cannot be persisted.
Sourcepub fn load_active_leases(&self, now: u64) -> Result<Vec<ProviderLease>>
pub fn load_active_leases(&self, now: u64) -> Result<Vec<ProviderLease>>
Load active (non-expired) provider leases from the database.
§Errors
Returns an error if the leases cannot be read.
Sourcepub fn insert_provider_ban(&self, ban: &BanRecord) -> Result<()>
pub fn insert_provider_ban(&self, ban: &BanRecord) -> Result<()>
Insert or replace a single provider ban record.
§Errors
Returns an error if the ban cannot be persisted.
Sourcepub fn load_active_bans(&self, now: u64) -> Result<Vec<BanRecord>>
pub fn load_active_bans(&self, now: u64) -> Result<Vec<BanRecord>>
Load active (non-expired) provider bans from the database.
§Errors
Returns an error if the bans cannot be read.
Sourcepub fn load_all_reputations(
&self,
) -> Result<HashMap<PublicKey, ProviderReputation>>
pub fn load_all_reputations( &self, ) -> Result<HashMap<PublicKey, ProviderReputation>>
Load all provider reputations from the database.
§Errors
Returns an error if the reputations cannot be read.
Sourcepub fn load_signal_sequences(
&self,
) -> Result<HashMap<(PublicKey, PublicKey), u64>>
pub fn load_signal_sequences( &self, ) -> Result<HashMap<(PublicKey, PublicKey), u64>>
Load all signal sequence numbers from the database.
§Errors
Returns an error if the sequences cannot be read.
Sourcepub fn upsert_reputation(
&self,
provider: &PublicKey,
rep: &ProviderReputation,
auto_ban_until: Option<u64>,
auto_ban_count: u32,
) -> Result<()>
pub fn upsert_reputation( &self, provider: &PublicKey, rep: &ProviderReputation, auto_ban_until: Option<u64>, auto_ban_count: u32, ) -> Result<()>
Sourcepub fn delete_stale_reputations(&self, now: u64, ttl_secs: u64) -> Result<()>
pub fn delete_stale_reputations(&self, now: u64, ttl_secs: u64) -> Result<()>
Delete stale reputation records last active before the given TTL.
§Errors
Returns an error if the deletion fails.
Sourcepub fn load_auto_bans(&self) -> Result<HashMap<PublicKey, (Option<u64>, u32)>>
pub fn load_auto_bans(&self) -> Result<HashMap<PublicKey, (Option<u64>, u32)>>
Load auto-ban information for all providers.
Returns a map of provider to (auto_ban_until, auto_ban_count).
§Errors
Returns an error if the data cannot be read.
Sourcepub fn upsert_signal_sequence(
&self,
reporter: &PublicKey,
provider: &PublicKey,
sequence: u64,
) -> Result<()>
pub fn upsert_signal_sequence( &self, reporter: &PublicKey, provider: &PublicKey, sequence: u64, ) -> Result<()>
Upsert a provider signal sequence tracker.
§Errors
Returns an error if the sequence cannot be persisted.
Sourcepub fn save_provider_trust_records(
&self,
records: &[ProviderTrustRecord],
) -> Result<()>
pub fn save_provider_trust_records( &self, records: &[ProviderTrustRecord], ) -> Result<()>
Save provider trust records to the database.
§Errors
Returns an error if the records cannot be persisted.
Sourcepub fn load_provider_trust_records(&self) -> Result<Vec<ProviderTrustRecord>>
pub fn load_provider_trust_records(&self) -> Result<Vec<ProviderTrustRecord>>
Load provider trust records from the database.
§Errors
Returns an error if the records cannot be read.
Sourcepub fn save_provider_trust_signals(
&self,
signals: &[ProviderTrustSignal],
) -> Result<()>
pub fn save_provider_trust_signals( &self, signals: &[ProviderTrustSignal], ) -> Result<()>
Save provider trust signals to the database.
§Errors
Returns an error if the signals cannot be persisted.
Sourcepub fn load_provider_trust_signals(&self) -> Result<Vec<ProviderTrustSignal>>
pub fn load_provider_trust_signals(&self) -> Result<Vec<ProviderTrustSignal>>
Load provider trust signals from the database.
§Errors
Returns an error if the signals cannot be read.
Sourcepub fn save_trust_streams(&self, streams: &[String]) -> Result<()>
pub fn save_trust_streams(&self, streams: &[String]) -> Result<()>
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