Expand description
A fluent, async, Datomic-style client for corium.
This crate is the ergonomic front door to the peer. It offers one API surface over two backends:
LocalPeerwraps thecorium_peer::Connectionlibrary, so queries run in-process against immutable database values read directly from storage — no round trip to the transactor.RemotePeerspeaks the peer-server gRPC protocol, presenting the same surface to processes that reach a hosted peer over the network.
Both implement the Peer trait and hand back Db values that share
the Db::query, Db::pull, Db::datoms, and time-view
(Db::as_of, Db::since, Db::history) methods.
Datalog queries and pull specifications are built as typesafe, immutable
values (see the query and pull modules) that lower to the boundary
EDN the engine parses, so a malformed query is a compile error rather than
a runtime parse failure.
use corium_client::{LocalPeer, Peer};
use corium_client::query::{Query, data, var, attr};
use corium_peer::ConnectConfig;
let peer = LocalPeer::connect(ConnectConfig::new("http://127.0.0.1:4334", "people")).await?;
let db = peer.db().await?;
let q = Query::find([var("name")])
.where_(data(var("e"), attr("person/name"), var("name")));
let result = db.query(&q, Default::default()).await?;
for row in result.rows() {
let name: String = row.get(0)?;
println!("{name}");
}Re-exports§
pub use crate::pull::Pull;pub use crate::query::Query;pub use crate::result::QueryResult;pub use crate::result::ResultShape;pub use crate::result::Row;pub use crate::tx::TxBuilder;pub use crate::tx::TxData;pub use crate::value::FromEdn;pub use crate::value::IntoEdn;
Modules§
- pull
- A typesafe, builder-patterned Pull specification.
- query
- A typesafe, builder-patterned Datalog query value.
- result
- Query results and typed row access.
- tx
- Transaction data as builder-patterned values.
- value
- Conversions between Rust values and boundary
Edn, used throughout the fluent API for query constants, transaction values, and typed result extraction.
Structs§
- Args
- Positional non-database arguments for a
Query’s:ininputs, in declaration order. - Datom
Row - One raw datom returned by
Db::datoms. Entity, attribute, and transaction positions are raw ids; the value is boundaryEdn. - Db
- An immutable database value.
- DbStats
- Coarse database statistics.
- Local
Peer - A fluent client backed by the in-process peer library.
- Remote
Peer - A fluent client backed by a remote peer server over gRPC.
- TxReport
- The result of a committed transaction.
Enums§
- Client
Error - A failure from the fluent client layer.
- Index
- A covering index, naming a datom-scan order.
- View
- A database time view.
Traits§
- Peer
- A live connection to a database, backed either by the local peer library or a remote peer server.