orientdb-rs
OrientDB Client
A Rust Client for OrientDB. Supports sync and async (tokio and async-std)
Installation
Install from crates.io
[]
= "*"
Cargo Features
async-std-runtime
: use the async APIs withasync-std
.tokio-runtime
: use the async APIs withtokio
.uuid
: Add support for UUID.sugar
: Add ergonimic APIs for querying and binding results to structs
Example
Basic Usage Synchronous
use ;
Basic Usage Asynchronous
For async-std
activate the feature async-std-runtime
orientdb-client = { version = "*", features = ["async-std-runtime"] }
use block_on;
use StreamExt;
use OrientDB;
use OrientResult;
For tokio
activate the feature tokio-runtime
orientdb-client = { version = "*", features = ["tokio-runtime"] }
use StreamExt;
use OrientDB;
use OrientResult;
async
Additional Features
sugar
feature
The sugar
feature add 3 methods to the query builder for spawning the query.
fetch_one
fetch
stream
for async oriter
for sync
They should be used instead of run
APIs when you want to execute the query and map the OResult
into a struct.
The sugar
is supported in sync and async mode.
fetch_one
Consume the stream and fetch the first result if any.
use FromResult;
// fetch one
let user: = session
.query
.fetch_one
.await?;
println!;`
fetch
Collect the stream to a Vec
and map to struct.
use FromResult;
// fetch
let user: = session
.query
.fetch
.await?;
println!;`
stream
Map each item of the stream to a struct.
use FromResult;
// fetch stream and collect
let stream = session
.query
.
.await?
.
.await;
println!;
Development
Compiling
git clone https://github.com/wolf4ood/orientdb-rs.git
cd orientdb-rs
cargo build
Running Tests
You can use docker-compose to start an instance for testing. Use the env variable ORIENTDB_SERVER
in order to specify the version of OrientDB
cd docker-compose
export ORIENTDB_SERVER=3.0.23
docker-compose up -d
cd ..
cargo test