4 stable releases

1.1.0 Jan 10, 2024
1.0.3 Jan 9, 2024

#1473 in Parser implementations

24 downloads per month

MIT-0 license

10KB
194 lines

RoSV - Rows of Serial Values implementation for Rust

I didn't really like the version included in the RSV Challenge repo, so I made my own.

This crate adds functionality to Vec<Vec<Option<String>>> and Vec<Vec<Option<&str>>> for serialization, and to Vec<u8> for deserialization. Bare functions for serialization and deserialization are available in rosv::serialization as well.

use rosv::{DeserializeRoSV, SerializeRoSV};

// Sample data
let rows = vec![
    vec![Some("Hello"), Some("🌎"), None, Some("")],
    vec![Some("A\0B\nC"), Some("Test 𝄞")],
    vec![],
    vec![Some("")],
];

// Return vec as a u8 stream readable by the rosv deserializer.
let stream = rows.serialize_rosv();

// Consume a stream and deserialize to a new vec.
let data = stream.deserialize_rosv().expect("Bad utf-8 in stream");

Dependencies

~57KB