ref: b3f677319228bead49f891199a321975c26265a3 zig-netstring/README.md -rw-r--r-- 865 bytes
b3f67731Caolan McMahon fix ziglang.org link 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