nom_bencode

Crates.ionom_bencode
lib.rsnom_bencode
version0.2.0
sourcesrc
created_at2022-07-05 09:25:22.442118
updated_at2023-02-08 13:23:08.610016
descriptionA bencode parser written with nom.
homepage
repositoryhttps://github.com/edg-l/nom-bencode/
max_upload_size
id619571
size392,330
Edgar (edg-l)

documentation

https://docs.rs/nom_bencode

README

nom_bencode

Version Downloads License Rust Docs

A bencode parser written with nom.

use nom_bencode::Value;

let data = nom_bencode::parse(b"d3:cow3:moo4:spam4:eggse").unwrap();
let v = data.first().unwrap();

if let Value::Dictionary(dict) = v {
    let v = dict.get("cow".as_bytes()).unwrap();

    if let Value::Bytes(data) = v {
        assert_eq!(data, b"moo");
    }

    let v = dict.get("spam".as_bytes()).unwrap();
    if let Value::Bytes(data) = v {
        assert_eq!(data, b"eggs");
    }
}

License: MIT OR Apache-2.0

Commit count: 17

cargo fmt