Function decodeZstandardFrameArrayList [src]
Decode a Zstandard from from src and return number of bytes read; see
decodeZstandardFrame(). The first four bytes of src must be the magic
number for a Zstandard frame.
Errors returned:
error.WindowSizeUnknown if the frame does not have a valid window size
error.WindowTooLarge if the window size is larger than
window_size_max
error.DictionaryIdFlagUnsupported if the frame uses a dictionary
error.ContentSizeTooLarge if the frame header indicates a content size
that is larger than std.math.maxInt(usize)
error.ChecksumFailure if verify_checksum is true and the frame
contains a checksum that does not match the checksum of the decompressed
data
error.ReservedBitSet if the reserved bit of the frame header is set
error.EndOfStream if src does not contain a complete frame
error.OutOfMemory if allocator cannot allocate enough memory
an error in block.Error if there are errors decoding a block
error.BadContentSize if the content size declared by the frame does
not equal the size of decompressed data
Prototype
pub fn decodeZstandardFrameArrayList( allocator: Allocator, dest: *std.ArrayList(u8), src: []const u8, verify_checksum: bool, window_size_max: usize, ) (error{OutOfMemory} || FrameContext.Error || FrameError)!usize
Parameters
allocator: Allocator
dest: *std.ArrayList(u8)
src: []const u8
verify_checksum: bool
window_size_max: usize
Source
pub fn decodeZstandardFrameArrayList(
allocator: Allocator,
dest: *std.ArrayList(u8),
src: []const u8,
verify_checksum: bool,
window_size_max: usize,
) (error{OutOfMemory} || FrameContext.Error || FrameError)!usize {
assert(std.mem.readInt(u32, src[0..4], .little) == frame.Zstandard.magic_number);
var consumed_count: usize = 4;
var frame_context = context: {
var fbs = std.io.fixedBufferStream(src[consumed_count..]);
const source = fbs.reader();
const frame_header = try decodeZstandardHeader(source);
consumed_count += fbs.pos;
break :context try FrameContext.init(frame_header, window_size_max, verify_checksum);
};
consumed_count += try decodeZstandardFrameBlocksArrayList(
allocator,
dest,
src[consumed_count..],
&frame_context,
);
return consumed_count;
}