support for zig 0.11
remove unused msg buffer from test case
use fixed buffer in README
Zig parser for netstrings.
Add src/netstring.zig
as a package in your build.zig
:
example.addPackagePath("netstring", "path/to/deps/netstring/src/netstring.zig");
const netstring = @import("netstring");
const std = @import("std");
pub fn main() !void {
var input = std.io.fixedBufferStream("5:hello,6:world!,");
var parser = netstring.netStringParser(input.reader());
var buf: [1024]u8 = undefined;
// Repeat while the parser can find another netstring
while (try parser.next()) |reader| {
// Read the current netstring and print it
const bytes = try reader.readAll(&buf);
std.debug.print("{s}\n", .{buf[0..bytes]});
}
}
Output:
hello
world!
$ zig build tests