authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-02-08 01:07:47+11:00
committergravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-02-20 09:09:06+11:00
log77ca1f7859f6b02399bb52f7d66becc3867036c6
treeab40d73cc926448c2a6a07ddc6a17fc8542ddb03
parentd9a90e181873d06b9e8632a86ff8c399e024974e

std.compress.zstandard: remove UnusedBitSet error


1 files changed, 3 insertions(+), 9 deletions(-)

lib/std/compress/zstandard/decompress.zig+3-9
......@@ -104,7 +104,6 @@ pub fn decodeAlloc(
104104/// contains a checksum that does not match the checksum of the decompressed
105105/// data
106106/// - `error.ReservedBitSet` if the reserved bit of the frame header is set
107/// - `error.UnusedBitSet` if the unused bit of the frame header is set
108107/// - `error.EndOfStream` if `src` does not contain a complete frame
109108/// - an error in `block.Error` if there are errors decoding a block
110109/// - `error.SkippableSizeTooLarge` if the frame is skippable and reports a
......@@ -153,7 +152,6 @@ pub const DecodedFrame = union(enum) {
153152/// contains a checksum that does not match the checksum of the decompressed
154153/// data
155154/// - `error.ReservedBitSet` if the reserved bit of the frame header is set
156/// - `error.UnusedBitSet` if the unused bit of the frame header is set
157155/// - `error.EndOfStream` if `src` does not contain a complete frame
158156/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory
159157/// - an error in `block.Error` if there are errors decoding a block
......@@ -192,7 +190,8 @@ const FrameError = error{
192190 ChecksumFailure,
193191 BadContentSize,
194192 EndOfStream,
195} || InvalidBit || block.Error;
193 ReservedBitSet,
194} || block.Error;
196195
197196/// Decode a Zstandard frame from `src` into `dest`, returning the number of
198197/// bytes read from `src` and written to `dest`. The first four bytes of `src`
......@@ -208,7 +207,6 @@ const FrameError = error{
208207/// contains a checksum that does not match the checksum of the decompressed
209208/// data
210209/// - `error.ReservedBitSet` if the reserved bit of the frame header is set
211/// - `error.UnusedBitSet` if the unused bit of the frame header is set
212210/// - `error.EndOfStream` if `src` does not contain a complete frame
213211/// - an error in `block.Error` if there are errors decoding a block
214212/// - `error.BadContentSize` if the content size declared by the frame does
......@@ -325,7 +323,6 @@ pub const FrameContext = struct {
325323/// contains a checksum that does not match the checksum of the decompressed
326324/// data
327325/// - `error.ReservedBitSet` if the reserved bit of the frame header is set
328/// - `error.UnusedBitSet` if the unused bit of the frame header is set
329326/// - `error.EndOfStream` if `src` does not contain a complete frame
330327/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory
331328/// - an error in `block.Error` if there are errors decoding a block
......@@ -465,17 +462,14 @@ pub fn frameWindowSize(header: frame.Zstandard.Header) ?u64 {
465462 } else return header.content_size;
466463}
467464
468const InvalidBit = error{ UnusedBitSet, ReservedBitSet };
469465/// Decode the header of a Zstandard frame.
470466///
471467/// Errors returned:
472/// - `error.UnusedBitSet` if the unused bits of the header are set
473468/// - `error.ReservedBitSet` if the reserved bits of the header are set
474469/// - `error.EndOfStream` if `source` does not contain a complete header
475pub fn decodeZstandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)!frame.Zstandard.Header {
470pub fn decodeZstandardHeader(source: anytype) error{ EndOfStream, ReservedBitSet }!frame.Zstandard.Header {
476471 const descriptor = @bitCast(frame.Zstandard.Header.Descriptor, try source.readByte());
477472
478 if (descriptor.unused) return error.UnusedBitSet;
479473 if (descriptor.reserved) return error.ReservedBitSet;
480474
481475 var window_descriptor: ?u8 = null;