https://github.com/nektro/zig-bencode
Bencode parser for Zig.
https://github.com/nektro/zig-bencode
bencode zig zig-package
Last synced: 9 months ago
JSON representation
Bencode parser for Zig.
- Host: GitHub
- URL: https://github.com/nektro/zig-bencode
- Owner: nektro
- License: mit
- Created: 2021-04-04T12:26:06.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-22T09:48:32.000Z (10 months ago)
- Last Synced: 2025-04-14T20:12:49.214Z (9 months ago)
- Topics: bencode, zig, zig-package
- Language: Zig
- Homepage:
- Size: 51.8 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zig-bencode

Bencode parser for Zig.
Uses the [Zigmod](https://github.com/nektro/zigmod) package manager.
https://en.wikipedia.org/wiki/Bencode
https://www.bittorrent.org/beps/bep_0003.html#bencoding
## Usage
Add the following to the bottom of your `zig.mod`
```yml
dependencies:
- src: git https://github.com/nektro/zig-bencode
```
In your code
```zig
const bencode = @import("bencode");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const alloc = &gpa.allocator;
const file = @embedFile("./some/path/to.torrent");
var buf = std.io.fixedBufferStream(file);
const r = buf.reader();
const ben = try bencode.parse(r, alloc);
// do something with `ben`...
}
```
## License
MIT