Function decodeAlloc [src]
Decodes a stream of frames from src; returns the decoded bytes. The stream
should not have extra trailing bytes - either all bytes in src will be
decoded, or an error will be returned.
Errors returned:
error.DictionaryIdFlagUnsupported if a src contains a frame that
uses a dictionary
error.MalformedFrame if a frame in src is invalid
error.OutOfMemory if allocator cannot allocate enough memory
Prototype
pub fn decodeAlloc( allocator: Allocator, src: []const u8, verify_checksum: bool, window_size_max: usize, ) error{ DictionaryIdFlagUnsupported, MalformedFrame, OutOfMemory }![]u8
Parameters
allocator: Allocator
src: []const u8
verify_checksum: bool
window_size_max: usize
Possible Errors
Source
pub fn decodeAlloc(
allocator: Allocator,
src: []const u8,
verify_checksum: bool,
window_size_max: usize,
) error{ DictionaryIdFlagUnsupported, MalformedFrame, OutOfMemory }![]u8 {
var result = std.ArrayList(u8).init(allocator);
errdefer result.deinit();
var read_count: usize = 0;
while (read_count < src.len) {
read_count += decodeFrameArrayList(
allocator,
&result,
src[read_count..],
verify_checksum,
window_size_max,
) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.DictionaryIdFlagUnsupported => return error.DictionaryIdFlagUnsupported,
else => return error.MalformedFrame,
};
}
return result.toOwnedSlice();
}