Skip to main content

SearchCatalog

Struct SearchCatalog 

pub struct SearchCatalog { /* private fields */ }
Expand description

A complete, incremental search catalogue keyed by canonical resource id.

Cloning a catalogue is O(1), so a widget can retain one instance and return a cheap provider handle whenever Ctrl+K opens. Mutations are recorded immediately and indexed in one batch before the next query. Queries are paged by both result count and work budget; result objects are cloned only for the hits in the requested page.

Fields are found by folded substring and ranked by the best weighted field match (see [tilo_search]). Bodies (SearchRecord::body) are found after every field hit, and a body source that names locations reports the segment a match is in. A unique item is found directly in a corpus of any size; broad queries continue through SearchCursor pages.

Implementations§

§

impl SearchCatalog

pub fn new(name: impl Into<Arc<str>>) -> SearchCatalog

pub fn detached(&self) -> SearchCatalog

An independent copy of this catalogue at its current generation. A session can extend the copy without the published catalogue — or any other session sharing it — observing the change.

pub fn replace_all( &self, rows: impl IntoIterator<Item = (String, String, SearchResult)>, ) -> Result<(), SearchCatalogError>

Replace an immutable snapshot in one generation. This is the bulk counterpart to Self::upsert: the whole snapshot is indexed in one build, while later incremental updates retain their existing semantics.

§Errors

Returns an error for malformed, duplicate, or non-canonical rows, or when catalogue generation/browse identities are exhausted.

pub fn replace_all_records( &self, records: impl IntoIterator<Item = SearchRecord>, ) -> Result<(), SearchCatalogError>

Self::replace_all for weighted records with optional bodies.

§Errors

As Self::replace_all.

pub fn sync( &self, rows: impl IntoIterator<Item = (String, String, SearchResult)>, ) -> Result<bool, SearchCatalogError>

Self::sync_records for legacy (resource id, searchable text, result) rows, as Self::replace_all takes them.

§Errors

As Self::sync_records.

pub fn sync_records( &self, records: impl IntoIterator<Item = SearchRecord>, ) -> Result<bool, SearchCatalogError>

Make records, in their order, the whole catalogue, as Self::replace_all_records would, indexing only the records that are new, changed or moved, and dropping those absent. Hits and browsing come in the same order a bulk replacement gives. The generation advances once if anything changed and not at all otherwise, so an unchanged snapshot keeps every cursor current.

The catalogue’s write lock is held only to compare and stage the records; indexing them waits for the next query or Self::index_bytes, incrementally when few changed.

§Errors

As Self::replace_all_records; the catalogue is then unchanged.

pub fn contains(&self, resource_id: &str) -> bool

Whether a canonical resource is currently retained by this catalogue.

pub fn upsert( &self, resource_id: impl Into<String>, searchable_text: impl AsRef<str>, result: SearchResult, ) -> Result<(), SearchCatalogError>

Insert or replace one durable resource. searchable_text may combine title, metadata and body; result is materialised only when it is a hit on a requested page.

§Errors

Returns SearchCatalogError when the stable id is empty, the result is legacy/opaque, or its canonical action addresses another resource.

pub fn upsert_record( &self, record: SearchRecord, ) -> Result<(), SearchCatalogError>

Self::upsert for a weighted record with an optional body.

§Errors

As Self::upsert.

pub fn remove(&self, resource_id: &str) -> bool

Remove one resource. Returns whether it existed.

pub fn stats(&self) -> SearchCatalogStats

pub fn index_bytes(&self) -> u64

Bytes the catalogue’s index occupies, once every mutation is indexed.

pub fn cursor_is_current(&self, cursor: &SearchCursor) -> bool

Whether a prior cursor belongs to this exact retained-index generation. The pull directory must turn a mismatch into a stale cursor response, never reinterpret it as an exhausted result set.

pub fn query_page( &self, query: &str, cursor: Option<&SearchCursor>, work_budget: usize, result_limit: usize, ) -> SearchPage

Query one deterministic page. Both budgets are hard ceilings. Continue with the returned cursor when next is set.

Trait Implementations§

§

impl CatalogSearchProvider for SearchCatalog

§

fn provider_name(&self) -> &str

Group label and diagnostic name, as SearchProvider::name.
§

fn catalog(&self) -> Option<SearchCatalog>

The catalogue answering queries, or None while none is published (a provider with no catalogue reports no generation and empty pages). Read more
§

const RESULT_LIMIT: usize = DEFAULT_SEARCH_RESULT_LIMIT

The largest page search and search_limited return. Providers whose palette section shows fewer rows lower it.
§

fn limited_work_budget(&self, _limit: usize) -> usize

Candidate-inspection budget for a one-shot search_limited(limit) call. The default inspects up to DEFAULT_SEARCH_CANDIDATE_LIMIT candidates to fill limit results; a provider may instead spend no more inspections than results it asked for. query_page caps either at the shared ceiling.
§

fn catalog_query<'q>(&self, query: &'q str) -> Cow<'q, str>

Rewrite the caller’s query into the form the catalogue was indexed with, for providers that fold their own text before indexing.
§

fn resolve_action_address(&self, _address: &ActionAddress) -> Option<Resource>

§

fn facets(&self) -> Vec<Facet>

§

fn search_scopes(&self) -> Vec<ScopeDecl>

As SearchProvider::search_scopes: the parts of the app this catalogue’s hits can be narrowed to.
§

fn admits(&self, _hit: &SearchResult, _query: &SearchQuery) -> bool

Whether hit passes query’s facet filters. The catalogue matches text only; a provider with facets checks the hit’s values here (query.admits("language", &[..])). The default admits every hit.
§

impl Clone for SearchCatalog

§

fn clone(&self) -> SearchCatalog

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
§

impl Debug for SearchCatalog

§

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

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

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> SearchProvider for T

§

fn name(&self) -> &str

The kind label this provider produces, used for diagnostics and as the default group header. Individual results may still carry a different SearchResult::kind.
§

fn action_directory_generation(&self) -> Option<u64>

Monotonic retained-index generation for the broker pull directory. None means the provider has not proved that a continuation cursor is safe across mutation, so remote directory discovery must omit it rather than silently advertise mutable rows as revision-stable. Providers backed by SearchCatalog should return Some(catalog.stats().generation).
§

fn action_directory_cursor_is_current(&self, cursor: &SearchCursor) -> bool

Validate a continuation token before it is used by a remote pull directory. The conservative default refuses it: only providers that expose a retained generation may claim continuation safety.
§

fn search(&self, query: &str) -> Vec<SearchResult>

Return the matching results for query. An empty query conventionally returns a provider’s “browse” set (recents / favourites / all), or an empty vec if browsing makes no sense for the source.
§

fn search_limited(&self, query: &str, limit: usize) -> Vec<SearchResult>

Query with a materialisation budget. App providers must override this and stop constructing hits once limit is reached. The fallback exists only for tiny/test providers outside apps/; the repository contract checker rejects app implementations that inherit it.
§

fn search_page( &self, query: &SearchQuery, cursor: Option<&SearchCursor>, work_budget: usize, result_limit: usize, ) -> SearchPage

Return one bounded continuation page for an interactive search. Read more
§

fn facets(&self) -> Vec<Facet>

The dimensions this provider filters by. The palette offers their values as chips and parses typed key:value tokens for them into SearchQuery::filters.
§

fn search_scopes(&self) -> Vec<ScopeDecl>

The parts of the app this provider’s hits can be narrowed to (see ScopeDecl). An unscoped palette offers each as a “Search in” row that narrows the search to it.
§

fn resolve_action_resource(&self, address: &ActionAddress) -> Option<Resource>

Lazily resolve a canonical search address that is intentionally absent from the small open-resource snapshot.
§

fn action_directory_invocation_domain(&self) -> ActionDirectoryInvocationDomain

Versions this actual provider’s complete lazy invocation domain, including hidden targets and argument/handler semantics omitted from search rows.
§

fn poll_page(&self, _token: &PendingToken) -> PagePoll

The page a SearchPage::pending token stands for, once its source has answered. Called on later frames, never in a loop; return PagePoll::Pending until the answer is in. A token the provider no longer knows (the query moved on) answers an empty ready page.
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,