Crates.io | benc0de |
lib.rs | benc0de |
version | 0.2.0 |
source | src |
created_at | 2020-10-23 14:09:32.246205 |
updated_at | 2020-10-23 19:03:00.371116 |
description | A super-faster bencode parser |
homepage | |
repository | |
max_upload_size | |
id | 304677 |
size | 14,769 |
Super-fast, zero-allocation bencode parser written in Rust.
Very fast! You can expect to parse AND extract data at a rate of 0.5 GB/s.
let bs = "d4:listli1ei2ee4:ping4:ponge".as_bytes(); // Bencode data to parse.
let parser = BenParser::new();
let mut root = parser.parse(bs);
// Iterate through list of numbers
for item in root.get("list").iter_numbers() {
// ...
}
// Get byte value from dict
let val = root.get("ping").bytes().unwrap();
// The parser is fault tolerant.
let val = root.get("ping").get("some_other").bytes(); // --> Returns None.
This library is especially fast, if you query dict entries alphabetically.
root.get("a").bytes().unwrap(); // Query bytes
root.get("b").number().unwrap(); // Query number (isize)
root.get("c").get("nested_entry").iter_bytes();
// Caching is also useful.
let c = root.get("c");
c.get("nested_entry1");
c.get("nested_entry2");
// ...