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 standard library.
std › compress › flate › Container › Hasher Public Union Hasher Doc Source Public Union std.compress.flate.Container.Hasher
pub const Hasher = union (Container ) Fields Functions File compress/flate.zig: 86
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 pub const Hasher = union (Container ) {
raw : void ,
gzip : struct {
crc : std .hash .Crc32 = .init (),
count : u32 = 0 ,
},
zlib : std .hash .Adler32 ,
pub fn init (containter : Container ) Hasher {
return switch (containter ) {
.gzip => .{ .gzip = .{} },
.zlib => .{ .zlib = .{} },
.raw => .raw ,
};
}
pub fn container (h : Hasher ) Container {
return h ;
}
pub fn update (h : *Hasher , buf : []const u8 ) void {
switch (h .*) {
.raw => {},
.gzip => |*gzip | {
gzip .crc .update (buf );
gzip .count +%= @truncate (buf .len );
},
.zlib => |*zlib | {
zlib .update (buf );
},
}
}
pub fn writeFooter (hasher : *Hasher , writer : *std .Io .Writer ) std .Io .Writer .Error !void {
switch (hasher .*) {
.gzip => |*gzip | {
// GZIP 8 bytes footer
// - 4 bytes, CRC32 (CRC-32)
// - 4 bytes, ISIZE (Input SIZE) - size of the original
// (uncompressed) input data modulo 2^32
try writer .writeInt (u32 , gzip .crc .final (), .little );
try writer .writeInt (u32 , gzip .count , .little );
},
.zlib => |*zlib | {
// ZLIB (RFC 1950) is big-endian, unlike GZIP (RFC 1952).
// 4 bytes of ADLER32 (Adler-32 checksum)
// Checksum value of the uncompressed data (excluding any
// dictionary data) computed according to Adler-32
// algorithm.
try writer .writeInt (u32 , zlib .adler , .big );
},
.raw => {},
}
}
}