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 › Compress › init Public Function init Doc Source 303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343 pub fn init (
output : *Writer ,
buffer : []u8 ,
container : flate .Container ,
opts : Options ,
) Writer .Error !Compress {
assert (output .buffer .len > 8 );
assert (buffer .len >= flate .max_window_len );
// note that disallowing some of these simplifies matching logic
assert (opts .chain != 0 ); // use `Huffman`; disallowing this simplies matching
assert (opts .good >= 3 and opts .nice >= 3 ); // a match will (usually) not be found
assert (opts .good <= 258 and opts .nice <= 258 ); // a longer match will not be found
assert (opts .lazy <= opts .nice ); // a longer match will (usually) not be found
if (opts .good <= opts .lazy ) assert (opts .chain >= 1 << 2 ); // chain can be reduced to zero
try output .writeAll (container .header ());
return .{
.writer = .{
.buffer = buffer ,
.vtable = &.{
.drain = drain ,
.flush = flush ,
.rebase = rebase ,
},
},
.history_len = 0 ,
.history_end_unhashed = false ,
.bit_writer = .init (output ),
.buffered_tokens = .empty ,
.lookup = .{
// init `value` is max so there is 0xff pattern
.head = @splat (.{ .value = math .maxInt (u15 ), .is_null = true }),
.chain = undefined ,
.chain_pos = math .maxInt (u15 ),
},
.container = container ,
.opts = opts ,
.hasher = .init (container ),
};
}
It is asserted
bufferis leastflate.max_window_lenbytes. It is assertedoutputhas a capacity of at least 8 bytes.