3 releases

0.3.2 May 7, 2024
0.3.1 Jun 16, 2021
0.3.0 Jan 30, 2021
0.2.2 Jan 25, 2021
0.1.2 Dec 24, 2020

#406 in Encoding

Download history 9/week @ 2024-06-16 7/week @ 2024-06-23 45/week @ 2024-06-30 4/week @ 2024-07-14 6/week @ 2024-07-21 7/week @ 2024-07-28 9/week @ 2024-08-11 2/week @ 2024-08-18 1/week @ 2024-08-25 1/week @ 2024-09-01 3/week @ 2024-09-15 20/week @ 2024-09-22 55/week @ 2024-09-29

78 downloads per month
Used in 2 crates (via vortex-dht)

MIT/Apache

61KB
1.5K SLoC

crates.io Docs dependency status

Crate for encoding/decoding bencode

What is bencode? It's the encoding mostly used in .torrent files and BitTorrent protocol. For more info see bep_0003.

Quick example

See examples directory

#[derive(Debug, Serialize, Deserialize)]
struct MetaInfo {
    info: Info,
    announce: String,
    #[serde(rename = "announce-list")]
    announce_list: Option<Vec<Vec<String>>>,
    #[serde(rename = "creation date")]
    creation_date: Option<u64>,
    comment: Option<String>,
    #[serde(rename = "created by")]
    created_by: Option<String>,
    encoding: Option<String>,
}

fn main(){
    let string = serde_bencoded::to_string(&MetaInfo{...}).unwrap;
    let mi: MetaInfo = serde_bencoded::from_str(&string).unwrap();
}

Dependencies

~230–520KB
~10K SLoC