Official Skytable client driver for Rust

Overview

Skytable client Crates.io docs.rs GitHub release (latest SemVer including pre-releases)

Introduction

This library is the official client for the free and open-source NoSQL database Skytable. First, go ahead and install Skytable by following the instructions here. This library supports all Skytable versions that work with the Skyhash 1.0 Protocol. This version of the library was tested with the latest Skytable release (release 0.6).

Using this library

This library only ships with the bare minimum that is required for interacting with Skytable. Once you have Skytable installed and running, you're ready to follow this guide!

We'll start by creating a new binary application and then running actions. Create a new binary application by running:

cargo new skyapp

Tip: You can see a full list of the available actions here.

First add this to your Cargo.toml file:

skytable = "0.3.0"

Now open up your src/main.rs file and establish a connection to the server while also adding some imports:

use skytable::{Connection, Query, Response, Element};
fn main() -> std::io::Result<()> {
    let mut con = Connection::new("127.0.0.1", 2003)?;
    Ok(())
}

Now let's run a Query! Change the previous code block to:

use skytable::{Connection, Query, Response, Element};
fn main() -> std::io::Result<()> {
    let mut con = Connection::new("127.0.0.1", 2003)?;
    let query = Query::from("heya");
    let res = con.run_simple_query(&query)?;
    assert_eq!(res, Response::Item(Element::String("HEY!".to_owned())));
    Ok(())
}

Way to go — you're all set! Now go ahead and run more advanced queries!

Async API

If you need to use an async API, just change your import to:

skytable = { version = "0.3.0", features=["async"], default-features= false }

You can now establish a connection by using skytable::AsyncConnection::new(), adding .awaits wherever necessary. Do note that you'll the Tokio runtime.

Using both sync and async APIs

With this client driver, it is possible to use both sync and async APIs at the same time. To do this, simply change your import to:

skytable = { version="0.3.0", features=["sync", "async"] }

MSRV

The MSRV for this crate is Rust 1.51, however, older rust versions are supported by adding the following backward compatibility flag in the features declaration for the dependency: compat-const-gen

Contributing

Open-source, and contributions ... — they're always welcome! For ideas and suggestions, create an issue on GitHub and for patches, fork and open those pull requests here!

License

This client library is distributed under the permissive Apache-2.0 License. Now go build great apps!

Comments
  • Error when querying the server

    Error when querying the server

    Problem: Bad response when querying:

    C:\Users\cmm\dev\local\skytest> cargo run  
        Finished dev [unoptimized + debuginfo] target(s) in 0.03s
         Running `target\debug\skytest.exe`
    Response: Item(Str("HEY!"))
    Response: Item(Str("HEY!"))
    Response: InvalidResponse
    Response: InvalidResponse
    Response: InvalidResponse
    Response: Item(Str("HEY!"))
    Response: InvalidResponse
    Response: Item(RespCode(PacketError))
    Response: InvalidResponse
    Response: InvalidResponse
    Response: Item(RespCode(PacketError))
    

    Platform: Windows 10 Pro 20H2 skyd 0.5.2 and 0.5.1

    I tried this: Cargo.toml

    [package]
    name = "skytest"
    version = "0.1.0"
    edition = "2018"
    
    [dependencies]
    skytable = "0.2.3"
    tokio = {version="1.5.0", features=["full"]}
    

    main.rs

    use skytable::{Connection, Query};
    
    #[tokio::main]
    async fn main() -> std::io::Result<()> {
        let mut con = Connection::new("127.0.0.1", 2003).await?;
        loop {
            let mut query = Query::new();
            query.arg("heya");
            let response = con.run_simple_query(query).await?;
            println!("Response: {:?}", response);
            std::thread::sleep(std::time::Duration::from_millis(200));
        }
    }
    
    bug 
    opened by martinmolin 22
  • Should most database operations be made to take `&self` and not `&mut self`?

    Should most database operations be made to take `&self` and not `&mut self`?

    I'm a relative Rust noob so this question may be off-base, but I noticed that most of the database operations take mutable references to the database, e.g. get uses this codepath: https://github.com/skytable/client-rust/blob/d6ca102e4c74dc7797d8639bf85ae42436f42584/src/actions.rs#L119

    As I said I'm a noob, but this makes it very hard (impossible?) to send several requests concurrently over the same connection, because Rust only lets at most one mutable borrow exist for a given object at any time.

    For comparison, RocksDB (which also allows concurrent access) treats most database operations as non-mutating, making it substantially easier to use with futures, e.g.: https://github.com/rust-rocksdb/rust-rocksdb/blob/b5b9e56d084aec2460bb50851757519b0387e198/src/db.rs#L939

    If I'm wrong and it is easy to spin off dozens of concurrent futures which interact with the database, could you add such an example to the examples folder? If not, consider marking these methods as non-mutable?

    opened by emchristiansen 7
  • Update README to use SkyResult in example code

    Update README to use SkyResult in example code

    Thank you for your work on SkyTable. When looking at the Rust Client, I noticed the current example code, did not compile because of the Result return type.

    use skytable::{Connection, Query, Element}; fn main() -> std::io::Result<()> { let mut con = Connection::new("127.0.0.1", 2003)?; Ok(()) }

    I updated the example to use 'SkyResult' instead.

    Thank you Nelius

    opened by neliusdelange 4
  • Add byte array to Query

    Add byte array to Query

    Currently Query::arg exists in order to add a String to a Query, this works really well with something like serde_json. However, it would be really convenient to also be able to add a Vec<u8> or similar directly to a Query in order to store a binary blob using something like bincode to serialize the data.

    documentation enhancement blocked 
    opened by martinmolin 2
  • Upgrade client to use the Skyhash protocol

    Upgrade client to use the Skyhash protocol

    If you're following skytable/skytable#148, Skytable is officially EOL-ing Terrapipe and introducing a new serialization protocol Skyhash. This issue serves to track our progress of upgrading to the Skyhash protocol

    documentation enhancement 
    opened by ohsayan 2
  • Adds impl FromSkyhashBytes for RawString and a TODO

    Adds impl FromSkyhashBytes for RawString and a TODO

    This is just a code sketch, as I'm a bit unclear on a couple things:

    1. I'm not sure why this wasn't already included (and I assume you have a good reason).
    2. I don't understand why you're encoding the key / value data the way you are. For example, in line 475 you seem to assume primitives are encoded as UTF8 strings, which seems very odd. Rather I'd expect everything in the DB to be (arbitrary, not UTF8) Vec<u8>s. I think you can convert all these primitives to bytes using functions like _.to_le_bytes().

    Relatedly, I'm not sure why you need the RawString type instead of just implementing the appropriate traits for Vec<u8>.

    opened by emchristiansen 2
  • impl FromSkyhashBytes for RawString

    impl FromSkyhashBytes for RawString

    There's an impl IntoSkyhashBytes for RawString but no impl FromSkyhashBytes for RawString, and I do not understand why. Can you either add this or add a note explaining why it doesn't make sense?

    Thanks!

    opened by emchristiansen 1
  • Entity/table for connection pooling?

    Entity/table for connection pooling?

    I see for the normal async there is a way to get the entity you wish to connect to. But for the async pool, there isn't.

    I could run a switch on every connection, but since it seems to send something to server, I am guessing there is a penalty? It would be nice if we can have the connections in the pool be able to be set with whichever entity/table we wish to use.

    Or maybe better assign a certain amount of connections per entity/table? This way it would avoid the penalty for lookup when switching? (unless the penalty isn't per connection/session?)


    Also, a little side comment. Not sure if you prefer it as a separate issue or here is fine. But the docker "latest" and "next" are the same thing (v0.8) where as latest should be v0.7.5. It also may make more sense to have smaller builds debian-slim / almalinux-minimum / almalinux-micro / alpine linux(if there is no issue with musl) instead of just the full stable build.

    enhancement good first issue 
    opened by KnowZero 1
Releases(v0.7.2)
Owner
Skytable
Skytable is a community-led project — working to build an extremely fast realtime NoSQL database
Skytable
Skytable is an extremely fast, secure and reliable real-time NoSQL database with automated snapshots and TLS

Skytable is an effort to provide the best of key/value stores, document stores and columnar databases, that is, simplicity, flexibility and queryability at scale. The name 'Skytable' exemplifies our vision to create a database that has limitless possibilities. Skytable was previously known as TerrabaseDB (and then Skybase) and is also nicknamed "STable", "Sky" and "SDB" by the community.

Skytable 1.4k Dec 29, 2022
Cassandra (CQL) driver for Rust, using the DataStax C/C++ driver under the covers.

cassandra-cpp This is a maintained Rust project that exposes the DataStax cpp driver at https://github.com/datastax/cpp-driver/ in a somewhat-sane cra

null 93 Jan 7, 2023
This is a maintained rust project that exposes the cpp driver at cpp-driver in a somewhat-sane crate.

cassandra-rs This is a maintained rust project that exposes the cpp driver at https://github.com/datastax/cpp-driver/ in a somewhat-sane crate. For th

Tupshin Harper 51 Aug 20, 2020
The official MongoDB Rust Driver

MongoDB Rust Driver This repository contains the officially supported MongoDB Rust driver, a client side library that can be used to interact with Mon

mongodb 1.1k Dec 30, 2022
This is superseded by the official MongoDB Rust Driver

This Repository is NOT a supported MongoDB product MongoDB Rust Driver Prototype NOTE: This driver is superseded by the official MongoDB Rust driver,

MongoDB, Inc. Labs 382 Nov 15, 2022
Official Rust client for Central Dogma

centraldogma-rs Official Rust Client for Central Dogma. Full documentation is available at https://docs.rs/centraldogma Getting started Installing Add

LINE 44 Oct 13, 2022
An ArangoDB driver for Rust

Rincon Rincon is an ArangoDB driver for Rust. It enables low level access to ArangoDB in a typesafe and Rust idiomatic manner. The name Rincon is deri

Innoave 35 Mar 21, 2021
TDS 7.2+ (mssql / Microsoft SQL Server) async driver for rust

Tiberius A native Microsoft SQL Server (TDS) client for Rust. Supported SQL Server versions Version Support level Notes 2019 Tested on CI 2017 Tested

Prisma 189 Dec 25, 2022
Asyncronous Rust Mysql driver based on Tokio.

mysql-async Tokio based asynchronous MySql client library for rust programming language. Installation Library hosted on crates.io. [dependencies] mysq

Anatoly I 292 Dec 30, 2022
Native PostgreSQL driver for the Rust programming language

Rust-Postgres PostgreSQL support for Rust. postgres Documentation A native, synchronous PostgreSQL client. tokio-postgres Documentation A native, asyn

Steven Fackler 2.8k Jan 8, 2023
cogo rust coroutine database driver (Mysql,Postgres,Sqlite)

cdbc Coroutine Database driver Connectivity.based on cogo High concurrency,based on coroutine No Future<'q,Output=*>,No async fn, No .await , no Poll*

co-rs 10 Nov 13, 2022
This is an Oracle database driver for Rust based on ODPI-C

Rust-oracle This is an Oracle database driver for Rust based on ODPI-C. Change Log See ChangeLog.md. Build-time Requirements C compiler. See Compile-t

Kubo Takehiro 138 Dec 23, 2022
Easy to use rust driver for arangoDB

arangors arangors is an intuitive rust client for ArangoDB, inspired by pyArango. arangors enables you to connect with ArangoDB server, access to data

fMeow 116 Jan 1, 2023
A Rust port of Pimoroni's uc8151 driver

uc8151-rs - a no-std Rust library for the UC8151(IL0373) e-ink display This is a Rust port of the Pimoroni UC8151 library. UC8151 is also sometimes re

null 6 Dec 15, 2022
ENC28J60 Linux network driver written in Rust.

enc28j60rs ENC28J60 Linux ethernet driver written in Rust. Tested with Raspberry Pi 4 Model B + Linux kernel 6.2.8 + Raspberry Pi OS AArch64. Kernel T

Ryo Munakata 11 May 1, 2023
MIPI Display Serial Interface unified driver

mipidsi This crate provides a generic display driver to connect to TFT displays that implement the MIPI DSI. Uses display_interface to talk to the har

Aleš Katona 31 Dec 20, 2022
TTVM Intermediate Representation driver

ttir - TTVM IR Driver ttir is driver for the TTVM IR located in ttvm. Usage Run the following command in your shell: cargo install ttir Features Easy

maDeveloper 1 Nov 2, 2021
e-paper/e-ink monitor linux driver

Ardoise: e-paper/e-ink monitor Goal: Create a e-paper/e-ink monitorfor linux. My personal use is a typewriter. Written in Rust Latency is 0,2s when th

Cyril Jacquet 1 Dec 8, 2022
An unofficial Logitech HID++>2.0 driver based on the original logiops by PixlOne

ruhroh An unofficial Logitech HID++>2.0 driver based on the original logiops by PixlOne Configuration Refer to the docs for details. The default locat

Matthew Wilks 3 Dec 11, 2022