ref: 74175ad59a5f6c1e0f56d8a046a22ad0eb24b8de zig-netstring/README.md -rw-r--r-- 896 bytes
74175ad5Caolan McMahon add output to example in README 8 months ago


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());

    // Repeat while the parser can find another netstring
    while (try parser.next()) {
        // Read the current netstring and print it
        const reader = parser.reader();
        const msg = try reader.readAllAlloc(std.heap.page_allocator, 4096);
        std.debug.print("{s}\n", .{msg});



#Running test suite

$ zig build tests