Skip to content

Repository files navigation

rust-librdb

Rust wrapper for librdb, the Redis RDB file parser.

Parses RDB dump files and delivers Redis data types (strings, lists, hashes, sets, sorted sets, streams, arrays, and more) through a callback trait, without loading the entire file into memory.

CrateDescription
librdbSafe, high-level wrapper
librdb-sysRaw FFI bindings

Installation

[dependencies]
librdb = "0.2"

By default, librdb is compiled from the vendored source (git submodule). A C compiler is required.

git clone --recurse-submodules https://github.com/funcpp/rust-librdb
cd rust-librdb
cargo build

Linking options

MethodHow
Source build (default)No extra steps
System shared library--features librdb-sys/dynamic-linking
Pre-built static librarySet DEP_LIBRDB_STATIC_ROOT, use --features librdb-sys/static-linking

Example

use librdb::{Parser,RdbHandlers,KeyInfo,Result};structMyHandler{keys:Vec<String>,}implRdbHandlersforMyHandler{fnhandle_new_key(&mutself,key:&[u8],_info:&KeyInfo) -> Result<()>{self.keys.push(String::from_utf8_lossy(key).into_owned());Ok(())}}fnmain() -> librdb::Result<()>{letmut parser = Parser::new(MyHandler{keys:vec![]})?;
parser.parse_file("dump.rdb")?;let handler = parser.into_handler();println!("{} keys parsed", handler.keys.len());Ok(())}

&[u8] callback parameters borrow directly from librdb's internal buffer and are only valid for the duration of the callback. Clone if you need to retain the data.

License

MIT

About

Rust wrapper for librdb (Redis RDB parser)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages