Skip to main content

QueryBuilder

Struct QueryBuilder 

Source
pub struct QueryBuilder<'hlx, 'a, R> { /* private fields */ }
Expand description

Fluent builder for a single request, produced by Client::query.

Optional header toggles (writer_only, warm_only, should_await_durability) and an optional body can be chained, then exactly one query kind is selected with stored or dynamic — both of which transition to a QueryRequest ready to send.

R is the response deserialization target carried through to send().

Implementations§

Source§

impl<'hlx, 'a, R> QueryBuilder<'hlx, 'a, R>

Source

pub fn new(client: &'hlx HelixDBClient) -> Self

Create a builder seeded with the Content-Type: application/json header.

Prefer Client::query, which calls this for you.

Source

pub fn writer_only(self) -> Self

Require the request to be served by a writer node.

Sets the x-helix-require-writer header.

Source

pub fn warm_only(self) -> Self

Only execute if the query is already warm (reads only).

Sets the x-helix-warm header.

Source

pub fn should_await_durability(self, should: bool) -> Self

Choose whether a write request blocks until the write is durable.

Sets the x-helix-await-durable header to "true" or "false".

Source

pub fn body<T: Serialize + Sync>(self, data: &T) -> Result<Self, HelixError>

Attach a serialized JSON request body.

Used to pass parameters to a stored query route. dynamic requests ignore this body — they serialize the DynamicQueryRequest itself as the payload.

§Errors

Returns HelixError::SerializationError if data cannot be serialized to JSON.

Source

pub fn stored(self, query_name: String) -> QueryRequest<'hlx, 'a, R>

Target a deployed stored query at /v1/query/<query_name>.

Pair with body to supply the query’s parameters, then call QueryRequest::send.

Source

pub fn dynamic(self, query: DynamicQueryRequest) -> QueryRequest<'hlx, 'a, R>

Target an inline dynamic query at /v1/query.

The DynamicQueryRequest (DSL query plus parameters) is serialized as the request body. Build one directly or with a #[register] helper, then call QueryRequest::send.

Auto Trait Implementations§

§

impl<'hlx, 'a, R> !RefUnwindSafe for QueryBuilder<'hlx, 'a, R>

§

impl<'hlx, 'a, R> !UnwindSafe for QueryBuilder<'hlx, 'a, R>

§

impl<'hlx, 'a, R> Freeze for QueryBuilder<'hlx, 'a, R>

§

impl<'hlx, 'a, R> Send for QueryBuilder<'hlx, 'a, R>
where R: Send,

§

impl<'hlx, 'a, R> Sync for QueryBuilder<'hlx, 'a, R>
where R: Sync,

§

impl<'hlx, 'a, R> Unpin for QueryBuilder<'hlx, 'a, R>
where R: Unpin,

§

impl<'hlx, 'a, R> UnsafeUnpin for QueryBuilder<'hlx, 'a, R>

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> ErasedDestructor for T
where T: 'static,

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> MaybeSendSync for T

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