3 releases

0.0.4 Jun 16, 2024
0.0.3 Jan 31, 2024
0.0.2 Jan 31, 2024

#562 in Encoding

Download history 1/week @ 2024-07-14 71/week @ 2024-07-28 6/week @ 2024-08-04 9/week @ 2024-08-11 16/week @ 2024-08-25 7/week @ 2024-09-01 4/week @ 2024-09-08 14/week @ 2024-09-15 30/week @ 2024-09-22 51/week @ 2024-09-29 14/week @ 2024-10-06 7/week @ 2024-10-13 10/week @ 2024-10-20 19/week @ 2024-10-27

53 downloads per month
Used in convert2json

MIT license

27KB
704 lines

rsv

an rsv reader and writer crate for Rust.

what is rsv?

rows of string values (rsv) is a modification on the csv format that replaces delimiter characters with unused unicode bytes. This makes encoding and decoding incredibly simple and consistent.

find the specification created by Stenway here

example

use rsv_core::reader::Reader;
use rsv_core::writer::Writer;
use serde::{Deserialize, Serialize};


#[derive(Debug, Deserialize, Serialize)]
struct ExampleStruct {
    _num: i32,
    _string: String,
    _option: Option<f64>,
    // _vec_option: Vec<Option<f64>>,
}


fn writer() {
    let mut w = Writer::from_path("basic-serde-example.bin").unwrap();
    let a = ExampleStruct { _num: 30202, _string: "Hello Stenway!".to_string(), _option: None };
    let b = ExampleStruct { _num: -30202, _string: "Hello Stenway!".to_string(), _option: Some(3.14) };


    w.serialize(&a).unwrap();
    w.serialize(&b).unwrap();
}


fn reader() {
    let mut r = Reader::from_path("basic-serde-example.bin").unwrap();


    // If the compiler is unable to implicitly determine the type you may need
    // to explicitly set it.
    let mut r = r.deserialize::<ExampleStruct>();


    println!("{:#?}", r.next().unwrap());
    println!("{:#?}", r.next().unwrap());
    assert!(r.next().is_none());
}

Dependencies

~0.3–1MB
~21K SLoC