Crates.io | raio |
lib.rs | raio |
version | 0.2.0 |
source | src |
created_at | 2019-11-24 16:30:24.54584 |
updated_at | 2020-11-21 11:11:12.549944 |
description | A neo4j+bolt driver written in Rust. |
homepage | https://github.com/aphorisme/raio-rs/README.md |
repository | https://github.com/aphorisme/raio-rs.git |
max_upload_size | |
id | 184001 |
size | 61,595 |
An opinionated async Bolt protocol client implementation written in Rust 🦀.
Supports Bolt Versions: | 4.1, 4.0 |
---|
⚠️ This is a rewrite of raio-0.1.0
. There is no migration possible.
⚠️ This package has yet to proof to be largely bug free.
⚠️ Be aware, that this package is based upon the specification and not upon another driver. It is part of a bigger project, hence heavy changes might appear in the future and it is opinionated.
The packs package drives the PackStream part.
The high-level entry-point is Client
which gives the functionality to run queries
and open transactions. It comes with a connection pool the handle asynchronous
actions.
use raio::client::{Client, ClientConfig};
use raio::client::auth::Basic;
use raio::client::error::ClientError;
use raio::messaging::query::Query;
#[async_std::test]
pub async fn auto_commit_simple() -> Result<(), ClientError> {
let auth = Basic::new("neo4j", "mastertest");
let client =
Client::create(
"localhost:7687",
auth,
ClientConfig::default("raio-rs-test", "0.2.0"));
let mut query = Query::new("RETURN $x + 1 as x, $y as y, $b as b");
query.param("x", 1);
query.param("y", Some(String::from("Hello")));
query.param("b", true);
let result =
client
.query(&query)
.await
.expect("Error while querying.");
let first =
result
.records()
.first()
.expect("Expected at least one result");
assert_eq!(first.get_field_typed("x"), Some(&2));
assert_eq!(first.get_field_typed("y"), Some(&String::from("Hello")));
assert_eq!(first.get_field_typed("b"), Some(&true));
Ok(())
}
You are welcome to contribute! This package is still in its very early days, so there will be bugs to be discovered and fixed, testing is quite short, documentation is lacking. Since I will use this package in a bigger project, progress will be made eventually, but any help is appreciated to turn this into a usable and performant bolt driver.