Skip to main content

PgSiftQuery

Struct PgSiftQuery 

Source
pub struct PgSiftQuery { /* private fields */ }

Implementations§

Source§

impl PgSiftQuery

Source

pub async fn buckets<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, requests: &[BucketRequest<E>], ) -> Result<Vec<BucketResult>, PgSearchError>
where E: SearchEntity,

Executes bounded time-series or numeric buckets with the same filters and authorization scope as the source query.

Source§

impl PgSiftQuery

Source

pub async fn diagnose<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<QueryDiagnosticReport, PgSearchError>
where E: SearchEntity,

Returns parameterized SQL, PostgreSQL JSON plans, and conservative index hints for an already authorized query. Callers should expose this admin-only operation behind their own authorization boundary.

Source§

impl PgSiftQuery

Source

pub async fn search_list<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Vec<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Source

pub async fn search_first<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Option<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Source

pub async fn count<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<i64, PgSearchError>
where E: SearchEntity,

Source

pub async fn sum<E, T, K>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, field: FieldRef<E, T, K>, ) -> Result<Option<<T as PgSumType>::Output>, PgSearchError>
where E: SearchEntity, T: PgSumType, K: SummableKind, <T as PgSumType>::Output: Send + Unpin + for<'row> Decode<'row, Postgres> + Type<Postgres>,

Source§

impl PgSiftQuery

Source

pub fn new(pool: Pool<Postgres>) -> PgSiftQuery

Source

pub fn with_policy( pool: Pool<Postgres>, policy: QueryPolicy, execution: PgExecutionPolicy, ) -> Result<PgSiftQuery, ConfigError>

Source

pub fn shape_cache_stats(&self) -> Option<ShapeCacheStats>

Source

pub fn clear_shape_cache(&self)

Source

pub fn with_scan_concurrency( self, active: usize, waiting: usize, ) -> Result<PgSiftQuery, ConfigError>

Configures a separate active/waiting scan budget shared by instance clones.

Source

pub fn with_partition_resolver<R>(self, resolver: R) -> PgSiftQuery
where R: PartitionResolver + 'static,

Source

pub fn with_sql_interceptor<I>(self, interceptor: I) -> PgSiftQuery
where I: SqlInterceptor + 'static,

Source

pub fn with_result_filter<F>(self, filter: F) -> PgSiftQuery
where F: ResultFilter + 'static,

Source

pub fn with_page_enricher<E>(self, enricher: E) -> PgSiftQuery
where E: PageEnricher + 'static,

Source

pub fn query_builder<E>(&self) -> QueryBuilder<'_, E>
where E: SearchEntity,

Source§

impl PgSiftQuery

Source

pub async fn search_on<E>( &self, connection: &mut PgConnection, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Page<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Executes a typed page in an existing connection or transaction.

Pass &mut *transaction for a sqlx transaction. This method does not begin/commit/rollback transactions or modify statement_timeout.

Source

pub async fn search_on_with<E>( &self, connection: &mut PgConnection, query: impl QueryInput<E>, scope: &ServerScope<E>, group_scope: &GroupScope<E>, options: Option<&SearchOptions<E>>, ) -> Result<Page<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Typed external execution with server-owned HAVING and summaries.

Source

pub async fn search_map_on<E>( &self, connection: &mut PgConnection, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Page<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Executes a dynamic map page on a caller-owned connection.

Source

pub async fn search_map_on_with<E>( &self, connection: &mut PgConnection, query: impl QueryInput<E>, scope: &ServerScope<E>, group_scope: &GroupScope<E>, options: Option<&SearchOptions<E>>, ) -> Result<Page<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Dynamic external execution with server-owned HAVING and summaries.

Source§

impl PgSiftQuery

Source

pub fn parse<E>(&self, raw: &RawParams) -> Result<UserQuery<E>, ParamError>
where E: SearchEntity,

Source§

impl PgSiftQuery

Source

pub async fn search_as_cursor<E, P>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<CursorPage<P>, PgSearchError>
where E: SearchEntity, P: SearchProjection<E> + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Executes a static typed projection as a cursor page without a count.

Source

pub async fn search_as<E, P>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Page<P>, PgSearchError>
where E: SearchEntity, P: SearchProjection<E> + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Source

pub async fn search_as_with<E, P>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, options: &SearchOptions<E>, ) -> Result<Page<P>, PgSearchError>
where E: SearchEntity, P: SearchProjection<E> + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Source§

impl PgSiftQuery

Source

pub async fn search_cursor<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<CursorPage<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Executes a cursor page with one bounded list query. The query must use the cursor paging mode (cursor= for the first page); no COUNT or summary query is issued.

Source

pub async fn search_map_cursor<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<CursorPage<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Dynamic map equivalent of Self::search_cursor.

Source

pub async fn search_authorized<E, C, P>( &self, query: impl QueryInput<E>, context: &C, provider: &P, ) -> Result<Page<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>, P: ScopeProvider<C, E>,

Executes a query after deriving its mandatory server scope from a trusted application context.

Source

pub async fn search_map_authorized<E, C, P>( &self, query: impl QueryInput<E>, context: &C, provider: &P, ) -> Result<Page<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity, P: ScopeProvider<C, E>,

Dynamic map equivalent of Self::search_authorized.

Source

pub async fn count_authorized<E, C, P>( &self, query: impl QueryInput<E>, context: &C, provider: &P, ) -> Result<i64, PgSearchError>
where E: SearchEntity, P: ScopeProvider<C, E>,

Count equivalent of Self::search_authorized.

Source

pub async fn search_enriched<E, R>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, enricher: &R, ) -> Result<Page<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>, R: TypedPageEnricher<E>,

Runs typed page enrichment only when explicitly requested by the caller.

Source

pub async fn search<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Page<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Source

pub async fn search_with_group_scope<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, group_scope: &GroupScope<E>, ) -> Result<Page<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Executes a page with an additional server-owned HAVING scope.

Source

pub async fn search_with<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, options: &SearchOptions<E>, ) -> Result<Page<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Source

pub async fn search_typed_with_scopes<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, group_scope: &GroupScope<E>, options: Option<&SearchOptions<E>>, ) -> Result<Page<E>, PgSearchError>
where E: SearchEntity + Send + Unpin + for<'row> FromRow<'row, PgRow>,

Executes a typed page with both server scopes and optional summaries.

Source

pub async fn search_map<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Page<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Source

pub async fn search_map_with_group_scope<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, group_scope: &GroupScope<E>, ) -> Result<Page<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Executes a dynamic map page with an additional server-owned HAVING scope.

Source

pub async fn search_map_with<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, options: &SearchOptions<E>, ) -> Result<Page<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Source

pub async fn search_map_with_scopes<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, group_scope: &GroupScope<E>, options: Option<&SearchOptions<E>>, ) -> Result<Page<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Executes a map page with both server scopes and optional summaries.

Source§

impl PgSiftQuery

Source

pub fn search_stream<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Pin<Box<dyn Stream<Item = Result<E, PgSearchError>> + Send>>, PgSearchError>
where E: SearchEntity + Send + Unpin + 'static + for<'row> FromRow<'row, PgRow>,

Streams a page without count. Early drop closes the checked-out connection so an active statement or timeout cannot return to the pool.

Source

pub fn search_map_stream<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, ) -> Result<Pin<Box<dyn Stream<Item = Result<IndexMap<String, RowValue>, PgSearchError>> + Send>>, PgSearchError>
where E: SearchEntity + Send + Unpin + 'static,

Source

pub fn scan<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, policy: ScanPolicy, ) -> Result<Pin<Box<dyn Future<Output = Result<Vec<E>, PgSearchError>> + Send>>, PgSearchError>
where E: SearchEntity + Send + Unpin + 'static + for<'row> FromRow<'row, PgRow>,

Explicit collecting convenience; prefer scan_stream for constant-memory use.

Source

pub fn scan_stream<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, policy: ScanPolicy, ) -> Result<Pin<Box<dyn Stream<Item = Result<E, PgSearchError>> + Send>>, PgSearchError>
where E: SearchEntity + Send + Unpin + 'static + for<'row> FromRow<'row, PgRow>,

Source

pub fn scan_map<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, policy: ScanPolicy, ) -> Result<Pin<Box<dyn Future<Output = Result<Vec<IndexMap<String, RowValue>>, PgSearchError>> + Send>>, PgSearchError>
where E: SearchEntity + Send + Unpin + 'static,

Source

pub fn scan_map_stream<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, policy: ScanPolicy, ) -> Result<Pin<Box<dyn Stream<Item = Result<IndexMap<String, RowValue>, PgSearchError>> + Send>>, PgSearchError>
where E: SearchEntity + Send + Unpin + 'static,

Source

pub fn scan_map_stream_with_scopes<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, group_scope: &GroupScope<E>, policy: ScanPolicy, ) -> Result<Pin<Box<dyn Stream<Item = Result<IndexMap<String, RowValue>, PgSearchError>> + Send>>, PgSearchError>
where E: SearchEntity + Send + Unpin + 'static,

Source§

impl PgSiftQuery

Source

pub async fn facets<E>( &self, query: impl QueryInput<E>, scope: &ServerScope<E>, requests: &[FacetRequest], ) -> Result<Vec<FacetResult>, PgSearchError>
where E: SearchEntity,

Executes bounded server-declared facets using the same query and row authorization scope. Facet fields and limits are validated before a connection is acquired.

Source

pub async fn search_map_with_facets<E>( &self, query: impl QueryInput<E> + Clone, scope: &ServerScope<E>, requests: &[FacetRequest], ) -> Result<FacetPage<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Convenience operation for dynamic list pages with facets.

Source

pub async fn facets_on<E>( &self, connection: &mut PgConnection, query: impl QueryInput<E>, scope: &ServerScope<E>, requests: &[FacetRequest], ) -> Result<Vec<FacetResult>, PgSearchError>
where E: SearchEntity,

Executes a facet on a caller-owned connection. This is useful when the caller has opened a read-only transaction and needs the list and facet queries to observe one snapshot.

Source

pub async fn search_map_with_facets_on<E>( &self, connection: &mut PgConnection, query: impl QueryInput<E> + Clone, scope: &ServerScope<E>, requests: &[FacetRequest], ) -> Result<FacetPage<IndexMap<String, RowValue>>, PgSearchError>
where E: SearchEntity,

Executes a map page and its facets on one caller-owned connection. Begin a read-only transaction before calling this method to obtain a consistent snapshot for both results.

Source§

impl PgSiftQuery

Source

pub fn with_query_observer<O>(self, observer: O) -> PgSiftQuery
where O: QueryObserver + 'static,

Source

pub fn with_slow_query_threshold(self, threshold: Duration) -> PgSiftQuery

Source

pub fn with_entity_slow_query_threshold<E>( self, threshold: Duration, ) -> PgSiftQuery
where E: SearchEntity,

Source§

impl PgSiftQuery

Source

pub async fn validate_schema<E>( &self, ) -> Result<SchemaValidationReport, PgSearchError>
where E: SearchEntity,

Validates an entity’s source, projection, predicates, grouping and aliases by asking PostgreSQL to plan the generated query.

EXPLAIN plans the statement without reading result rows. This makes the method suitable for application startup and CI contract checks; it does not inspect information_schema and does not mutate the database.

Trait Implementations§

Source§

impl Clone for PgSiftQuery

Source§

fn clone(&self) -> PgSiftQuery

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 PgSiftQuery

Source§

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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