https://github.com/knightpp/serde_bencoded
Yet another encoding/decoding library for bencode
https://github.com/knightpp/serde_bencoded
bencode rust torrent
Last synced: 10 months ago
JSON representation
Yet another encoding/decoding library for bencode
- Host: GitHub
- URL: https://github.com/knightpp/serde_bencoded
- Owner: knightpp
- License: apache-2.0
- Created: 2020-12-03T10:16:45.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-13T13:19:39.000Z (over 1 year ago)
- Last Synced: 2025-03-26T11:04:02.500Z (10 months ago)
- Topics: bencode, rust, torrent
- Language: Rust
- Homepage:
- Size: 121 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
[](https://crates.io/crates/serde_bencoded)
[](https://docs.rs/serde_bencoded/)
[](https://deps.rs/crate/serde_bencoded/)
# 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](https://www.bittorrent.org/beps/bep_0003.html).
# Quick example
See `examples` directory
```rust
#[derive(Debug, Serialize, Deserialize)]
struct MetaInfo {
info: Info,
announce: String,
#[serde(rename = "announce-list")]
announce_list: Option>>,
#[serde(rename = "creation date")]
creation_date: Option,
comment: Option,
#[serde(rename = "created by")]
created_by: Option,
encoding: Option,
}
fn main(){
let string = serde_bencoded::to_string(&MetaInfo{...}).unwrap;
let mi: MetaInfo = serde_bencoded::from_str(&string).unwrap();
}
```