#binary-format #codec #file-format #binary-encoding #data #tabular #utf-8

librsv

A simple crate for encoding/decoding the RSV file format (Rows of String Values)

2 releases

0.1.1 Jan 12, 2024
0.1.0 Jan 12, 2024

#2120 in Encoding

32 downloads per month

MIT license

13KB
192 lines

Full documentation: https://docs.rs/librsv/0.1.0/librsv/

RSV (Rows of String Values) is a very simple binary format for encoding tabular data. It is similar to CSV, but even simpler due to the avoidance of escape characters. This is achieved by encoding strings as UTF-8, and using bytes that can never appear in valid UTF-8 strings as delimiters.

The full specification can be found at: https://github.com/Stenway/RSV-Specification

Basic usage

There are three convenience methods for encoding and decoding RSV documents in one go:

  • encode_rsv - Encodes an RSV document from a structure such as Vec<Vec<Option<String>>>.
  • decode_rsv- Decodes an RSV document into a Vec<Vec<Option<String>>>.
  • decode_rsv_borrowed- Decodes an RSV document into a Vec<Vec<Option<&str>>>.
use librsv::{encode_rsv, decode_rsv};

let data = vec![
    vec![Some("Hello".into()), Some("world".into())],
    vec![Some("asdf".into()), None, Some("".into())],
];

let encoded = encode_rsv(&data);
let decoded = decode_rsv(&encoded).unwrap();

assert_eq!(data, decoded);

Dependencies

~0.4–0.8MB
~19K SLoC