Crate okv

Crate okv 

Source
Expand description

§OKV - Okay Key-Value Storage

docs.rs Crates.io Crates.io

OKV is a versatile key-value storage library designed for Rust. It offers a simple yet powerful API, inspired by the heed crate, and supports various databases and serialization formats.

§Features

  • Multiple Database Backends:
    • memdb: In-memory database for rapid prototyping and testing.
    • rocksdb: RocksDB integration for robust, disk-based storage.
  • Serialization Formats:
    • serde_json: JSON serialization for human-readable data storage.
    • rmp-serde: MessagePack serialization for efficient binary format.

§Installation

Add OKV to your project:

cargo add okv

§Quick Start

use okv::{Env};
use okv::backend::memory::MemDB;

fn main() -> eyre::Result<()> {
    // initialize the storage backend
    let memdb = MemDB::new();
    let env = Env::new(memdb);

    // open a database with the specified key and value types
    let db = env.open::<&str, &str>("my_database")?;

    // Working with data
    db.set_nx("key", "val")?;
    assert_eq!(db.get("key")?, Some("val".to_string()));

    Ok(())
}

§Supported Types

OKV can work with any type that implements Serialize. Additionally, it supports the following types out of the box without any serialization overhead:

§Acknowledgements

Special thanks to the authors of the heed crate for their inspiring work, which greatly influenced the development of OKV.

§License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in OKV by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. OKV - Okay Key-Value Storage

Modules§

backend
Database backends
types
Serialization types

Structs§

Database
A collection of key-value pairs
DatabaseTransaction
A temporary transaction database
Env
A database environment

Enums§

DecodeError
An error that can occur when decoding a value.
EncodeError
An error that can occur when encoding a value.
Error
An error that can occur when interacting with the database.

Traits§

DBCommon
A trait that represents a common database interface.
DBCommonClear
A trait that represents a common database interface can be cleared.
DBCommonDelete
A database that supports deletion.
DBCommonIter
A database that supports iterators.
DBCommonIterPrefix
A database that supports iterators over a prefix.
DBCommonRef
A database that can return references.
DBCommonRefBatch
A database that can return references in batches.