bencode
Super-fast, zero-allocation bencode parser written in Rust.
How fast is it?
Very fast! You can expect to parse AND extract data at a rate of 0.5 GB/s.
Quick start
let bs = "d4:listli1ei2ee4:ping4:ponge".as_bytes; // Bencode data to parse.
let parser = new;
let mut root = parser.parse;
// Iterate through list of numbers
for item in root.get.iter_numbers
// Get byte value from dict
let val = root.get.bytes.unwrap;
// The parser is fault tolerant.
let val = root.get.get.bytes; // --> Returns None.
Performance tip
This library is especially fast, if you query dict entries alphabetically.
root.get.bytes.unwrap; // Query bytes
root.get.number.unwrap; // Query number (isize)
root.get.get.iter_bytes;
// Caching is also useful.
let c = root.get;
c.get;
c.get;
// ...
Comments
- This is my first Rust project, so feel free to comment on this.