Crates.io | juicy_bencode |
lib.rs | juicy_bencode |
version | 0.1.2 |
source | src |
created_at | 2022-06-28 21:19:25.003284 |
updated_at | 2022-06-29 19:54:51.015514 |
description | A little parser for bencode using the Nom library |
homepage | |
repository | https://github.com/Internal-Compiler-Error/juicy_bencode |
max_upload_size | |
id | 615049 |
size | 24,612 |
A little parser for bencode using the Nom library. Nom eats input byte by byte, and bencode is such juicy input!
The crate provides both more individual parses for parsing out individual bencode items or just a blob.
You have a bencoded blob containing the torrent information for totally legal files,
// pub enum BencodeItemView<'a> {
// Integer(i64),
// ByteString(&'a [u8]),
// List(Vec<BencodeItemView<'a>>),
// Dictionary(BTreeMap<&'a [u8], BencodeItemView<'a>>),
// }
use juicy_bencode::parse_bencode_dict;
fn main () -> Result<(), Box<dyn Error>>{
// the library uses byte slices
let text: &[u8] = input();
// now you can do totally legal things with the info!
let parsed_tree: BencodeItemView = parse_bencode_dict(text)?;
}