Skip to main content

IndexingDatabase

Struct IndexingDatabase 

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

Thread-safe SQLite database used by the indexing service.

Implementations§

Source§

impl IndexingDatabase

Source

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.

Source

pub fn in_memory() -> Result<Self>

Create an isolated in-memory indexing database.

§Errors

Returns an error if SQLite cannot initialize the schema.

Source

pub fn path(&self) -> &Path

Source

pub fn schema_version(&self) -> Result<String>

Return the persisted indexing schema version.

§Errors

Returns an error if the schema metadata cannot be read.

Source

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.

Source

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.

Source

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.

Source

pub fn folder_count(&self) -> Result<usize>

Return the number of opted-in folders.

§Errors

Returns an error if SQLite cannot query the database.

Source

pub fn entry_count(&self) -> Result<usize>

Return the number of indexed entries.

§Errors

Returns an error if SQLite cannot query the database.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn catalog_count(&self) -> Result<usize>

Return the number of known catalogs.

§Errors

Returns an error if SQLite cannot query the database.

Source

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.

Source

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.

Source

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.

Source

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.

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.

Search all known catalogs. Alias for Self::search_catalogs.

§Errors

Returns an error if the query is invalid or SQLite cannot read results.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn save_denylist_rules(&self, rules: &[DenylistRule]) -> Result<()>

Persist denylist rules to the database.

§Errors

Returns an error if the rules cannot be saved.

Source

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.

Source

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.

Source

pub fn upsert_filter_list(&self, list: &FilterList) -> Result<()>

Upsert a filter list subscription.

§Errors

Returns an error if the filter list cannot be persisted.

Load stable links from the database.

§Errors

Returns an error if the links cannot be read.

Save stable links to the database.

§Errors

Returns an error if the links cannot be persisted.

Upsert a single mutable pointer to the stable links table.

§Errors

Returns an error if the pointer cannot be persisted.

Insert a single mirror ticket.

§Errors

Returns an error if the mirror cannot be persisted.

Source

pub fn save_leases(&self, leases: &[ProviderLease]) -> Result<()>

Save provider leases to the database.

§Errors

Returns an error if the leases cannot be persisted.

Source

pub fn load_leases(&self) -> Result<Vec<ProviderLease>>

Load provider leases from the database.

§Errors

Returns an error if the leases cannot be read.

Source

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.

Source

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.

Source

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.

Source

pub fn load_moderation_records(&self) -> Result<Vec<ModerationRecord>>

Load moderation records from the database.

§Errors

Returns an error if the records cannot be read.

Source

pub fn save_attestations(&self, attestations: &[Attestation]) -> Result<()>

Save attestations to the database.

§Errors

Returns an error if the attestations cannot be persisted.

Source

pub fn load_attestations(&self) -> Result<Vec<Attestation>>

Load attestations from the database.

§Errors

Returns an error if the attestations cannot be read.

Source

pub fn save_content_reports(&self, reports: &[ReportRecord]) -> Result<()>

Save content reports to the database.

§Errors

Returns an error if the reports cannot be persisted.

Source

pub fn load_content_reports(&self) -> Result<Vec<ReportRecord>>

Load content reports from the database.

§Errors

Returns an error if the reports cannot be read.

Source

pub fn save_provider_bans(&self, bans: &[BanRecord]) -> Result<()>

Save provider bans to the database.

§Errors

Returns an error if the bans cannot be persisted.

Source

pub fn load_provider_bans(&self) -> Result<Vec<BanRecord>>

Load provider bans from the database.

§Errors

Returns an error if the bans cannot be read.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn upsert_reputation( &self, provider: &PublicKey, rep: &ProviderReputation, auto_ban_until: Option<u64>, auto_ban_count: u32, ) -> Result<()>

Upsert a provider reputation record.

§Errors

Returns an error if the record cannot be persisted.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn save_trust_streams(&self, streams: &[String]) -> Result<()>

Save trust streams to the database.

§Errors

Returns an error if the streams cannot be persisted.

Source

pub fn load_trust_streams(&self) -> Result<Vec<String>>

Load trust streams from the database.

§Errors

Returns an error if the streams cannot be read.

Trait Implementations§

Source§

impl Clone for IndexingDatabase

Source§

fn clone(&self) -> IndexingDatabase

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IndexingDatabase

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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