10 releases

0.1.9 Jan 17, 2024
0.1.8 Jan 17, 2024
0.1.5 Nov 13, 2023
0.1.2 Oct 18, 2023

#1918 in Database interfaces

MIT license

24KB
701 lines

lexi-rs

a rust client for lexidb, an in memory data structure database.

Getting started

install this package

$ cargo add lexi-rs

Basic Usage

currently, values that are set must implement Into. Data types that implement this trait include:

  1. &str
  2. String,
  3. i8, u8, i16, u16, i32, u32, i64, f32, f64

use lexi;
use anyhow;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
  let mut client = Client::new(<address>)?;
  client.connect.await?;

  let set_res = client.set("key", "value").await?;
  assert_eq!(set_res, lexi::LexiType::Simple(SimpleString::Ok));

  let get_res = client.get("key").await?;
  assert_eq!(get_res, lexi::LexiType::BulkString("value".to_owned()));

  let del_res = client.del("key").await?;
  assert_eq!(del_res, lexi::LexiType::Simple(SimpleString::Ok));

  Ok(())
}

stack

let push_res = client.push("vince").await?;
assert_eq!(push_res, LexiType::Simple(SimpleString::Ok));

let pop_res = client.pop().await?;
assert_eq!(pop_res, LexiType::BulkString("vince".to_owned());

queue

let enque_res = client.enque("vince").await?;
assert_eq!(enque_res, LexiType::Simple(SimpleString::Ok));

let deque_res = client.deque().await?;
assert_eq!(deque_res, LexiType::BulkString("vince".to_owned());

Dependencies

~3–11MB
~118K SLoC