Expand description
A native Rust query client for Pylon — lets a Rust project run PyQL
queries against a Pylon-managed Postgres database directly, without
going through pylon-py/pyo3. Query results decode either into a
generic, dynamically-typed Value/Object or into a caller’s own
row struct via Queryable and #[derive(Queryable)] — there is no
generated per-schema-type code either way.
Compilation reuses pylon_core::query::compile as-is; connection
execution reuses pylon_pgcon::PgPool/PgTransaction as-is. The one
genuinely new piece is decode, which walks a compiled query’s
ShapeNode alongside its decoded DecodedValue row — the Rust
counterpart of pylon/query.py’s _decode (which only ever ran
Python-side, operating on already-Pythonized values).
Re-exports§
pub use query_arg::QueryArg;pub use query_arg::QueryArgs;pub use query_arg::ValueOpt;pub use queryable::DecodeError;pub use queryable::DecodeErrorKind;pub use queryable::Queryable;
Modules§
- json
- A decoded result rendered as JSON, the way Gel renders its own: objects carry exactly the pointers their shape selected, in shape order; temporal values are ISO 8601 strings; durations are ISO 8601 durations; bytes are base64; enums are their label; decimals keep every digit.
- query_
arg - Query arguments:
QueryArgfor a single value,QueryArgsfor the collection a query method takes, andValueOpt+ [named_args!] for building a named collection inline. - queryable
Queryable— decoding a genericValueinto a caller’s own type, and the helpers#[derive(Queryable)]generates calls to.
Macros§
- named_
args - Builds a named argument collection for a query with
$nameparameters:
Structs§
- Builder
- Builds a
Client.dsnis required up front (this crate never parsespylon.toml— see the crate-level docs); everything else has a sensible default. - Cache
Stats - Snapshot of a cache’s current size — see
Cache::stat. - Channel
Listener - A live subscription to one
Channel, returned bycrate::Client::listen. - Client
- An async Pylon client — a connection pool plus a compiled schema,
shared cheaply across every
Client::with_globals/Client::with_configview of it (mirrorspylon/client.py’s own shared-pool-ref pattern). - Group
- Result of a
groupstatement: one grouping key, the grouping label list, and the elements sharing that key. - Object
- A schema object, a free object literal, or a named tuple — all three
decode to the same by-name field-access shape.
type_nameisSomeonly for a real schema type (including the concrete type of a polymorphic interface query result) or a registered named tuple;Nonefor a free object (select { a := 1 }) or an unregistered structural named tuple. - Range
- A PostgreSQL range value.
lower/upperareNonefor an unbounded side;empty == truemeans the whole range is empty (lower/upperare meaningless then, not “both unbounded”). - Transaction
- A single transaction attempt, handed to the closure passed to
crate::Client::transaction. Exposes the same query methods ascrate::Clientitself (minusanalyze, which the Python client also never runs inside an explicit transaction).
Enums§
- Decoded
Value - Error
- Isolation
- PostgreSQL transaction isolation level. Defaults to
Serializable, matchingpylon/client.py’s own default. - Value
- A decoded query result value. One variant per
ShapeNode/DecodedValuekinddecode.rsknows how to produce — see that module for the walk that builds these.
Type Aliases§
- Result
- TxFuture
- A transaction attempt body’s return type — boxed since a plain generic
Fut: Futurecan’t express “this future borrows the&Transactionit was handed” without higher-ranked lifetimes on the future type itself; boxing sidesteps that and matches how most async-closure-taking APIs in the ecosystem handle exactly this shape.
Derive Macros§
- Queryable
#[derive(Queryable)]. Shares the trait’s name the wayserde’s derives share theirs — a macro and a trait live in separate namespaces, so oneuse pylon_client::Queryable;brings in both.