# Rust Query Clients

_Peios / Developing for Peios / Events_

> Choosing finite, streaming, or wire-level eventd client APIs.

The `eventd-client` Rust crate provides query framing and client lifecycle
handling. It shares access-right constants with the daemon so that clients
can describe policy without implementing the authorization decision.

The default `access` feature includes the local access-policy helpers.
Query-only consumers can turn off default features without changing the
server's authorization of their queries.

## Finite queries

`query` returns the complete result after the server's terminal response.
A server error discards the accumulated initial records. The call blocks,
so a graphical client must keep it off its interface thread.

The result is a vector in client memory. Server resource limits do not
make that client allocation a fixed-size buffer. Choose bounded queries
or use the wire interface when an application needs a different storage
strategy.

`wire::Connection::bounded(stream, max_frame_bytes)` rejects an oversized
response-frame length before reserving its body. A rejected frame ends the
connection. Reconnect instead of trying to skip the body. The bound applies
to encoded frame bytes; decoded values and retained result collections need
separate memory bounds. `Connection::new` retains its protocol-sized bound.

## Streaming queries

`Tail` reads a `STREAM` query on a worker thread. It reports the complete
initial result, live batches, and the reason the stream ended. Dropping the
handle shuts down the connection and releases the receiving channel.

The channel capacity bounds queued reports, not their total bytes.
A client that stops consuming reports eventually stops reading the socket,
and the server can disconnect it. A client must handle that end state;
reconnecting does not provide a resume cursor.

## Query text and policy

Use the crate's `text` helpers to quote values when constructing queries.
Do not concatenate untrusted strings as query syntax.

The `access` module can describe relevant registry policy to a person.
Only eventd, using kernel access checks and the socket peer token,
authorizes a query. A client's policy preview cannot replace that check.

See the manual's
[client library reference](/peios/reference/eventd/evctl/eventd-client.md) for lifecycle
and wire details.
