Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

PackHeader

git.PackHeader
const PackHeader = struct

File

Code

const PackHeader = struct {
    total_objects: u32,

    const signature = "PACK";
    const supported_version = 2;

    fn read(reader: *Io.Reader) !PackHeader {
        const actual_signature = reader.take(4) catch |e| switch (e) {
            error.EndOfStream => return error.InvalidHeader,
            else => |other| return other,
        };
        if (!mem.eql(u8, actual_signature, signature)) return error.InvalidHeader;
        const version = reader.takeInt(u32, .big) catch |e| switch (e) {
            error.EndOfStream => return error.InvalidHeader,
            else => |other| return other,
        };
        if (version != supported_version) return error.UnsupportedVersion;
        const total_objects = reader.takeInt(u32, .big) catch |e| switch (e) {
            error.EndOfStream => return error.InvalidHeader,
            else => |other| return other,
        };
        return .{ .total_objects = total_objects };
    }
}