#bencode-parser #zero #torrent #encoder #read-file

benko

A zero dependency bencode parser/encoder

4 stable releases

2.0.2 Feb 24, 2021
1.0.0 Jan 28, 2021

#1618 in Encoding

27 downloads per month
Used in torq

MIT license

24KB
582 lines

benko

A zero dependency bencode parser and encoder written in rust.

Want to use benko for Torrents? check out tijb/torq

Getting Started

Check out the docs. docs.rs/benko

Examples

read from a file

  let bytes: Vec<u8> = std::fs::read("my_file.torrent")
    .expect("Couldn't read file.");
  let bencode: Benc = Benc::parse(bytes)
    .expect("Couldn't parse bencode bytes");

encode to bytes

  let bencode: Benc = Benc::Int(9001);
  let bytes: Vec<u8> = bencode.bytes();

Issues?

Feel free to put up a Pull Request, or open an Issue. :)


lib.rs:

A zero dependency Bencode parsing library.

To get started try passing a bencoded byte array to Benc::parse().

No runtime deps