Skip to main content

Module client

Module client 

Source
Expand description

High-level synchronous client for Hyper database.

This module provides Client, the primary synchronous interface for communicating with a Hyper server. It supports three query execution modes, each using a different level of the PostgreSQL wire protocol:

  • Simple Query (Client::query) — Sends a single Query message and collects all DataRow messages into memory. Results are returned in text format. Best for small result sets or DDL/DML commands.

  • Extended Query / HyperBinary (Client::query_fast) — Uses the Extended Query protocol (Parse / Bind / Execute) with ColumnFormat::HyperBinary (format code 2) for LittleEndian binary results. Returns StreamRows that compute field offsets on-demand, avoiding per-row allocation.

  • Streaming (Client::query_streaming) — Like query_fast but returns a QueryStream that yields rows in chunks, keeping memory usage constant regardless of result set size. The stream holds the connection lock for its lifetime; dropping it triggers a cancel request to stop the server from streaming the rest.

§Bulk Insertion (COPY Protocol)

Client::copy_in starts a COPY ... FROM STDIN WITH (FORMAT HYPERBINARY) session and returns a CopyInWriter for streaming binary data. The caller is responsible for encoding rows in the correct format (typically done by the higher-level hyperdb_api::Inserter). See also copy_in_with_format for alternative formats (CSV, Arrow IPC) and copy_in_raw for fully custom COPY statements.

Structs§

Client
A synchronous client for Hyper database.
CopyInWriter
A writer for COPY IN operations.
QueryStream
Streaming iterator for query results without materializing all rows.