Coder Social home page Coder Social logo

shaneutt / pickledb-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from seladb/pickledb-rs

0.0 1.0 0.0 105 KB

PickleDB-rs is a lightweight and simple key-value store. It is a Rust version for Python's PickleDB

License: MIT License

Rust 100.00%

pickledb-rs's Introduction

PickleDB

Build Status Crate API

PickleDB is a lightweight and simple key-value store written in Rust, heavily inspired by Python's PickleDB

PickleDB is fun and easy to use

use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod};

fn main() {

    // create a new DB with AutoDump (meaning every change is written to the file)
    // and with Json serialization (meaning DB will be dumped to file as a Json object)
    let mut db = PickleDb::new("example.db", PickleDbDumpPolicy::AutoDump, SerializationMethod::Json);

    // set the value 100 to the key 'key1'
    db.set("key1", &100).unwrap();

    // print the value of key1
    println!("The value of key1 is: {}", db.get::<i32>("key1").unwrap());

    // load the DB from the same file
    let db2 = PickleDb::load("example.db", PickleDbDumpPolicy::DumpUponRequest, SerializationMethod::Json).unwrap();

    // print the value of key1
    println!("The value of key1 as loaded from file is: {}", db2.get::<i32>("key1").unwrap());
}

Installation

This crate works with Cargo and can be found in crates.io Add this to your Cargo.toml:

[dependencies]
pickledb = "0.4.0"

Documentation

All documentation for this crate can be found in docs.rs

Examples

There are currently two examples shipped with PickleDB:

  • Hello World which shows the basic usage of PickleDB: create a new DB, load a DB from file, get/set key-value pairs of different types, and more
  • Lists which shows how to use lists in PickleDB: create new lists, add/remove items from lists, retrieve items from lists, remove lists, and more

Changelog

Version 0.4.0

  • Changed all doc tests from ignore to no_run so generated docs don't contain untested warnings
  • Changed both instances of lextend to take iterators of references rather than a slice of values
  • Fixed bug in load_test()
  • Fixed rustfmt and clippy warnings
  • Added examples to Cargo.toml to allow them to be run via Cargo

Version 0.3.0

  • Added new serialization options. Now PickleDB supports JSON, Bincode, YAML and CBOR serializations
  • Added proper error handling (Issue #3)
  • Use Path and PathBuf instead of strings to describe DB paths
  • Better organization of the code

Version 0.2.0

pickledb-rs's People

Contributors

seladb avatar mkaput avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.