Giter VIP home page Giter VIP logo

rdb-rs's Introduction

rdb-rs - RDB parsing, formatting, analyzing. All in one library

crates.io Build Status Clippy Linting Result

Inspired and based on redis-rdb-tools.

Documentation

Online at rdb.fnordig.de/doc/rdb/.

Build

cargo build --release

Minimum required Rust version: 1.6.0

Install

make install

You can change the path by setting PREFIX. Defaults to /usr.

Basic operation

rdb-rs exposes just one important method: parse. This methods takes care of reading the RDB from a stream, parsing the containted data and calling the provided formatter with already-parsed values.

use std::io::BufReader;
use std::fs::File;
use std::path::Path;

let file = File::open(&Path::new("dump.rdb")).unwrap();
let reader = BufReader::new(file);
rdb::parse(reader, rdb::formatter::JSON::new(), rdb::filter::Simple::new());

Formatter

rdb-rs brings 4 pre-defined formatters, which can be used:

  • Plain: Just plain output for testing
  • JSON: JSON-encoded output
  • Nil: Surpresses all output
  • Protocol: Formats the data in RESP, the Redis Serialization Protocol

These formatters adhere to the Formatter trait and supply a method for each possible datatype or opcode. Its up to the formatter to correctly handle all provided data such as lists, sets, hashes, expires and metadata.

Command-line

rdb-rs brings a Command Line application as well.

This application will take a RDB file as input and format it in the specified format (JSON by default).

Example:

$ rdb --format json dump.rdb
[{"key":"value"}]
$ rdb --format protocol dump.rdb
*2
$6
SELECT
$1
0
*3
$3
SET
$3
key
$5
value

Tests

Run tests with:

make test

This will run the code tests with cargo as well as checking that it can parse all included dump files.

Contribute

If you find bugs or want to help otherwise, please open an issue.

License

MIT. See LICENSE.

rdb-rs's People

Contributors

badboy avatar jwilm avatar lilymara-onesignal avatar llogiq avatar timbuchwaldt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.