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 › LiteralsSection › Streams › decode Private Function decode Doc Source Private Function std.compress.zstd.Decompress.LiteralsSection.Streams.decode
fn decode (size_format : u2 , stream_data : []const u8 ) !Streams Params size_format : u2 stream_data : []const u8 File compress/zstd/Decompress.zig: 967
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991 fn decode (size_format : u2 , stream_data : []const u8 ) !Streams {
if (size_format == 0 ) {
return .{ .one = stream_data };
}
if (stream_data .len < 6 ) return error .MalformedLiteralsSection ;
const stream_1_length : usize = std .mem .readInt (u16 , stream_data [0 ..2 ], .little );
const stream_2_length : usize = std .mem .readInt (u16 , stream_data [2 ..4 ], .little );
const stream_3_length : usize = std .mem .readInt (u16 , stream_data [4 ..6 ], .little );
const stream_1_start = 6 ;
const stream_2_start = stream_1_start + stream_1_length ;
const stream_3_start = stream_2_start + stream_2_length ;
const stream_4_start = stream_3_start + stream_3_length ;
if (stream_data .len < stream_4_start ) return error .MalformedLiteralsSection ;
return .{ .four = .{
stream_data [stream_1_start .. stream_1_start + stream_1_length ],
stream_data [stream_2_start .. stream_2_start + stream_2_length ],
stream_data [stream_3_start .. stream_3_start + stream_3_length ],
stream_data [stream_4_start ..],
} };
}