Crate nom_bencode

source ·
Expand description

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");
    }
}

Re-exports

pub use errors::BencodeError;

Modules

Errors produced by this library.

Enums

The Err enum indicates the parser was not successful
A bencode value.

Functions

Parses the provided bencode source.