Function decode [src]
Decodes frames from src into dest; returns the length of the result.
The stream should not have extra trailing bytes - either all bytes in src
will be decoded, or an error will be returned. An error will be returned if
a Zstandard frame in src does not declare its content size.
Errors returned:
error.DictionaryIdFlagUnsupported if a src contains a frame that
uses a dictionary
error.MalformedFrame if a frame in src is invalid
error.UnknownContentSizeUnsupported if a frame in src does not
declare its content size
Prototype
pub fn decode(dest: []u8, src: []const u8, verify_checksum: bool) error{ MalformedFrame, UnknownContentSizeUnsupported, DictionaryIdFlagUnsupported, }!usize
Parameters
dest: []u8
src: []const u8
verify_checksum: bool
Possible Errors
Source
pub fn decode(dest: []u8, src: []const u8, verify_checksum: bool) error{
MalformedFrame,
UnknownContentSizeUnsupported,
DictionaryIdFlagUnsupported,
}!usize {
var write_count: usize = 0;
var read_count: usize = 0;
while (read_count < src.len) {
const counts = decodeFrame(dest, src[read_count..], verify_checksum) catch |err| {
switch (err) {
error.UnknownContentSizeUnsupported => return error.UnknownContentSizeUnsupported,
error.DictionaryIdFlagUnsupported => return error.DictionaryIdFlagUnsupported,
else => return error.MalformedFrame,
}
};
read_count += counts.read_count;
write_count += counts.write_count;
}
return write_count;
}