Rust connector
Use raftdb-client, the Rust reference connector.
The Rust connector speaks the Raft DB binary protocol (specification) and offers the same operations as every other connector. It is the crate raftdb-client. Download the package from the Download page.
No TLS yet. User names, passwords and tokens travel in clear text. Use only on trusted networks.
Requirements#
The crate raftdb-client. It has no dependencies besides raftdb-proto and no async runtime; the client is blocking.
Install#
Download the package from the Download page and unzip it. It holds three crates (raftdb-client, raftdb-proto, raftdb-doc) that refer to each other by relative path; keep them side by side. Add a path dependency to your Cargo.toml:
[dependencies]
raftdb-client = { path = "raftdb-rust-connector/raftdb-client" }If you unpack the folder inside a Cargo workspace of your own, list it under exclude there, or unpack it outside the workspace. Rust 1.89 or newer; cargo compiles the crates with your program.
use raftdb_client::Client;
fn main() -> Result<(), raftdb_client::ClientError> {
let addr = "127.0.0.1:7480".parse().unwrap();
let mut c = Client::connect_user(addr, "YOUR_USER", "YOUR_PASSWORD")?;
c.put_json(b"u1", r#"{"name":"Asha","age":31}"#)?;
println!("{:?}", c.get_json(b"u1")?);
Ok(())
}Connect and query#
The client has two levels:
- One-shot calls, one round trip each:
connect,connect_str("host:port", credential),connect_user,use_table,ping,put_json,get_json,delete,count,sql_count,filter_page,sql_page,create_index; and the callsget,put,insertfor callers that already hold documents in the binary format. - Streaming:
scan(filter, page)andscan_sql(sql, page)return an iterator over every row as JSON text, following the server's cursor page after page; and the low-levelsend,flushandrecv, which put many requests on the wire before reading replies.
Credentials: empty for an open server, the shared token, or connect_user(addr, user, password).
Beyond the other connectors, the Rust client has Mux (many callers on few connections, as streams), deferred writes (set_defer, sync) and projections of fields, all on protocol version 2 (SPEC sections 7 and 10).
Errors#
ClientError::{Io, Protocol, Server{code, msg}}; code is one of raftdb_proto::code (SPEC section 3).
Conformance status#
The reference connector of the other languages. It is tested by the server's own test suite, which uses it for every call. The scenarios are listed in the specification page.