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 › zstd › Decompress › SequencesSection › Header › decode Public Function decode Doc Source Public Function std.compress.zstd.Decompress.SequencesSection.Header.decode
pub fn decode (in : *Reader , remaining : *Limit ) DecodeError !Header Params File compress/zstd/Decompress.zig: 1376
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412 pub fn decode (in : *Reader , remaining : *Limit ) DecodeError !Header {
var sequence_count : u24 = undefined ;
remaining .* = remaining .subtract (1 ) orelse return error .EndOfStream ;
const byte0 = try in .takeByte ();
if (byte0 == 0 ) {
return .{
.sequence_count = 0 ,
.offsets = undefined ,
.match_lengths = undefined ,
.literal_lengths = undefined ,
};
} else if (byte0 < 128 ) {
remaining .* = remaining .subtract (1 ) orelse return error .EndOfStream ;
sequence_count = byte0 ;
} else if (byte0 < 255 ) {
remaining .* = remaining .subtract (2 ) orelse return error .EndOfStream ;
sequence_count = (@as (u24 , (byte0 - 128 )) << 8 ) + try in .takeByte ();
} else {
remaining .* = remaining .subtract (3 ) orelse return error .EndOfStream ;
sequence_count = (try in .takeByte ()) + (@as (u24 , try in .takeByte ()) << 8 ) + 0x7F00 ;
}
const compression_modes = try in .takeByte ();
const matches_mode : Header .Mode = @fromBackingInt (@intCast ((compression_modes & 0b00001100 ) >> 2 ));
const offsets_mode : Header .Mode = @fromBackingInt (@intCast ((compression_modes & 0b00110000 ) >> 4 ));
const literal_mode : Header .Mode = @fromBackingInt (@intCast ((compression_modes & 0b11000000 ) >> 6 ));
if (compression_modes & 0b11 != 0 ) return error .ReservedBitSet ;
return .{
.sequence_count = sequence_count ,
.offsets = offsets_mode ,
.match_lengths = matches_mode ,
.literal_lengths = literal_mode ,
};
}