1/nektro/bencode v0.5
zig-bencode
Bencode parser for Zig.
Uses the 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
dependencies:
- src: git https://github.com/nektro/zig-bencode
In your code
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
Package Contents
- .gitattributes
- LICENSE
- zig.sum
- build.zig
- archlinux-2021.04.01-x86_64.iso.torrent
- src/lib.zig
- src/main.zig
- README.md
- zig.mod
- build.zig.zon
- .gitignore