Skip to main content

pylon_client/
lib.rs

1//
2// This source file is part of the Pylon open source project.
3//
4// Copyright (c) 2026 Jaldis B.V.
5//
6// Licensed under the MIT OR Apache-2.0 license (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10//     https://opensource.org/licenses/MIT
11//     https://www.apache.org/licenses/LICENSE-2.0
12//
13// Unless required by applicable law or agreed to in writing, software
14// distributed under the License is distributed on an "AS IS" BASIS,
15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16// See the License for the specific language governing permissions and
17// limitations under the License.
18//
19
20//! A native Rust query client for Pylon — lets a Rust project run PyQL
21//! queries against a Pylon-managed Postgres database directly, without
22//! going through `pylon-py`/pyo3. Query results decode either into a
23//! generic, dynamically-typed [`Value`]/[`Object`] or into a caller's own
24//! row struct via [`Queryable`] and `#[derive(Queryable)]` — there is no
25//! generated per-schema-type code either way.
26//!
27//! Compilation reuses `pylon_core::query::compile` as-is; connection
28//! execution reuses `pylon_pgcon::PgPool`/`PgTransaction` as-is. The one
29//! genuinely new piece is `decode`, which walks a compiled query's
30//! `ShapeNode` alongside its decoded `DecodedValue` row — the Rust
31//! counterpart of `pylon/query.py`'s `_decode` (which only ever ran
32//! Python-side, operating on already-Pythonized values).
33
34mod cache;
35mod client;
36mod decode;
37mod error;
38mod exec;
39pub mod json;
40mod listen;
41pub mod query_arg;
42pub mod queryable;
43mod schema;
44mod transaction;
45mod value;
46
47pub use client::{Builder, Client, TxFuture};
48pub use error::{Error, Result};
49pub use listen::ChannelListener;
50pub use pylon_cache::CacheStats;
51pub use pylon_value::DecodedValue;
52pub use query_arg::{QueryArg, QueryArgs, ValueOpt};
53pub use queryable::{DecodeError, DecodeErrorKind, Queryable};
54pub use transaction::{Isolation, Transaction};
55pub use value::{Group, Object, Range, Value};
56
57/// `#[derive(Queryable)]`. Shares the trait's name the way `serde`'s derives
58/// share theirs — a macro and a trait live in separate namespaces, so one
59/// `use pylon_client::Queryable;` brings in both.
60pub use pylon_derive::Queryable;