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: about 1 month 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 (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T09:17:28.000Z (about 2 years ago)
- Last Synced: 2025-03-29T03:41:38.395Z (about 2 months ago)
- Topics: bencode-parser, rust, rust-crate, torrent
- Language: Rust
- Homepage:
- Size: 365 KB
- Stars: 11
- 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