Skip to main content

Crate pylon_client

Crate pylon_client 

Source
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: 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: QueryArg for a single value, QueryArgs for the collection a query method takes, and ValueOpt + [named_args!] for building a named collection inline.
queryable
Queryable — decoding a generic Value into 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 $name parameters:

Structs§

Builder
Builds a Client. dsn is required up front (this crate never parses pylon.toml — see the crate-level docs); everything else has a sensible default.
CacheStats
Snapshot of a cache’s current size — see Cache::stat.
ChannelListener
A live subscription to one Channel, returned by crate::Client::listen.
Client
An async Pylon client — a connection pool plus a compiled schema, shared cheaply across every Client::with_globals/Client::with_config view of it (mirrors pylon/client.py’s own shared-pool-ref pattern).
Group
Result of a group statement: 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_name is Some only for a real schema type (including the concrete type of a polymorphic interface query result) or a registered named tuple; None for a free object (select { a := 1 }) or an unregistered structural named tuple.
Range
A PostgreSQL range value. lower/upper are None for an unbounded side; empty == true means the whole range is empty (lower/upper are meaningless then, not “both unbounded”).
Transaction
A single transaction attempt, handed to the closure passed to crate::Client::transaction. Exposes the same query methods as crate::Client itself (minus analyze, which the Python client also never runs inside an explicit transaction).

Enums§

DecodedValue
Error
Isolation
PostgreSQL transaction isolation level. Defaults to Serializable, matching pylon/client.py’s own default.
Value
A decoded query result value. One variant per ShapeNode/DecodedValue kind decode.rs knows 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: Future can’t express “this future borrows the &Transaction it 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 way serde’s derives share theirs — a macro and a trait live in separate namespaces, so one use pylon_client::Queryable; brings in both.