mmkv 0.1.2

Rust version of MMKV
Documentation
mmkv-0.1.2 has been yanked.

Crates.io PRs Welcome Crates.io Crates.io

Library uses file-based mmap to store key-values

This is a simple rust version of mmkv, only part of the core features have been implemented so far, and it is still far from production availability.

How to use

Add dependency:

[dependencies]
mmkv = { version = "0.1.0" }

And use MMKV directly:

use mmkv::MMKV;

fn main() {
    // initialize it with a directory, 
    // the library will crate a file,
    // named "mini_mmkv" under this dir
    MMKV::initialize(".");
    MMKV::put_i32("key1", 1);
    // Some(1)
    println!("{:?}", MMKV::get_i32("key1"));
    MMKV::put_str("key1", "value");
    // None, cause "key1" was override by put_str
    println!("{:?}", MMKV::get_i32("key1"));
    // Some("value")
    println!("{:?}", MMKV::get_str("key1"));
    MMKV::put_bool("key1", true);
    // Some(true)
    println!("{:?}", MMKV::get_bool("key1"));
}