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>
impl<'hlx, 'a, R> QueryBuilder<'hlx, 'a, R>
Sourcepub fn new(client: &'hlx HelixDBClient) -> Self
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.
Sourcepub fn writer_only(self) -> Self
pub fn writer_only(self) -> Self
Require the request to be served by a writer node.
Sets the x-helix-require-writer header.
Sourcepub fn warm_only(self) -> Self
pub fn warm_only(self) -> Self
Only execute if the query is already warm (reads only).
Sets the x-helix-warm header.
Sourcepub fn should_await_durability(self, should: bool) -> Self
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".
Sourcepub fn body<T: Serialize + Sync>(self, data: &T) -> Result<Self, HelixError>
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.
Sourcepub fn stored(self, query_name: String) -> QueryRequest<'hlx, 'a, R>
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.
Sourcepub fn dynamic(self, query: DynamicQueryRequest) -> QueryRequest<'hlx, 'a, R>
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.