https://github.com/edg-l/nom-bencode
A bencode parser written with nom.
https://github.com/edg-l/nom-bencode
bencode-parser rust rust-crate torrent
Last synced: 3 days ago
JSON representation
A bencode parser written with nom.
- Host: GitHub
- URL: https://github.com/edg-l/nom-bencode
- Owner: edg-l
- License: apache-2.0
- Created: 2022-07-05T09:18:18.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T09:17:28.000Z (about 2 years ago)
- Last Synced: 2025-06-23T04:43:49.174Z (22 days ago)
- Topics: bencode-parser, rust, rust-crate, torrent
- Language: Rust
- Homepage:
- Size: 365 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# nom_bencode
[](https://crates.io/crates/nom_bencode)
[](https://crates.io/crates/nom_bencode)
[](https://crates.io/crates/nom_bencode)

[](https://docs.rs/nom_bencode)A bencode parser written with nom.
```rust
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