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(...@@ -104,7 +104,6 @@ pub fn decodeAlloc(
104/// contains a checksum that does not match the checksum of the decompressed104/// contains a checksum that does not match the checksum of the decompressed
105/// data105/// data
106/// - `error.ReservedBitSet` if the reserved bit of the frame header is set106/// - `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
108/// - `error.EndOfStream` if `src` does not contain a complete frame107/// - `error.EndOfStream` if `src` does not contain a complete frame
109/// - an error in `block.Error` if there are errors decoding a block108/// - an error in `block.Error` if there are errors decoding a block
110/// - `error.SkippableSizeTooLarge` if the frame is skippable and reports a109/// - `error.SkippableSizeTooLarge` if the frame is skippable and reports a
...@@ -153,7 +152,6 @@ pub const DecodedFrame = union(enum) {...@@ -153,7 +152,6 @@ pub const DecodedFrame = union(enum) {
153/// contains a checksum that does not match the checksum of the decompressed152/// contains a checksum that does not match the checksum of the decompressed
154/// data153/// data
155/// - `error.ReservedBitSet` if the reserved bit of the frame header is set154/// - `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
157/// - `error.EndOfStream` if `src` does not contain a complete frame155/// - `error.EndOfStream` if `src` does not contain a complete frame
158/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory156/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory
159/// - an error in `block.Error` if there are errors decoding a block157/// - an error in `block.Error` if there are errors decoding a block
...@@ -192,7 +190,8 @@ const FrameError = error{...@@ -192,7 +190,8 @@ const FrameError = error{
192 ChecksumFailure,190 ChecksumFailure,
193 BadContentSize,191 BadContentSize,
194 EndOfStream,192 EndOfStream,
195} || InvalidBit || block.Error;193 ReservedBitSet,
194} || block.Error;
196195
197/// Decode a Zstandard frame from `src` into `dest`, returning the number of196/// Decode a Zstandard frame from `src` into `dest`, returning the number of
198/// bytes read from `src` and written to `dest`. The first four bytes of `src`197/// bytes read from `src` and written to `dest`. The first four bytes of `src`
...@@ -208,7 +207,6 @@ const FrameError = error{...@@ -208,7 +207,6 @@ const FrameError = error{
208/// contains a checksum that does not match the checksum of the decompressed207/// contains a checksum that does not match the checksum of the decompressed
209/// data208/// data
210/// - `error.ReservedBitSet` if the reserved bit of the frame header is set209/// - `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
212/// - `error.EndOfStream` if `src` does not contain a complete frame210/// - `error.EndOfStream` if `src` does not contain a complete frame
213/// - an error in `block.Error` if there are errors decoding a block211/// - an error in `block.Error` if there are errors decoding a block
214/// - `error.BadContentSize` if the content size declared by the frame does212/// - `error.BadContentSize` if the content size declared by the frame does
...@@ -325,7 +323,6 @@ pub const FrameContext = struct {...@@ -325,7 +323,6 @@ pub const FrameContext = struct {
325/// contains a checksum that does not match the checksum of the decompressed323/// contains a checksum that does not match the checksum of the decompressed
326/// data324/// data
327/// - `error.ReservedBitSet` if the reserved bit of the frame header is set325/// - `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
329/// - `error.EndOfStream` if `src` does not contain a complete frame326/// - `error.EndOfStream` if `src` does not contain a complete frame
330/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory327/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory
331/// - an error in `block.Error` if there are errors decoding a block328/// - an error in `block.Error` if there are errors decoding a block
...@@ -465,17 +462,14 @@ pub fn frameWindowSize(header: frame.Zstandard.Header) ?u64 {...@@ -465,17 +462,14 @@ pub fn frameWindowSize(header: frame.Zstandard.Header) ?u64 {
465 } else return header.content_size;462 } else return header.content_size;
466}463}
467464
468const InvalidBit = error{ UnusedBitSet, ReservedBitSet };
469/// Decode the header of a Zstandard frame.465/// Decode the header of a Zstandard frame.
470///466///
471/// Errors returned:467/// Errors returned:
472/// - `error.UnusedBitSet` if the unused bits of the header are set
473/// - `error.ReservedBitSet` if the reserved bits of the header are set468/// - `error.ReservedBitSet` if the reserved bits of the header are set
474/// - `error.EndOfStream` if `source` does not contain a complete header469/// - `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 {
476 const descriptor = @bitCast(frame.Zstandard.Header.Descriptor, try source.readByte());471 const descriptor = @bitCast(frame.Zstandard.Header.Descriptor, try source.readByte());
477472
478 if (descriptor.unused) return error.UnusedBitSet;
479 if (descriptor.reserved) return error.ReservedBitSet;473 if (descriptor.reserved) return error.ReservedBitSet;
480474
481 var window_descriptor: ?u8 = null;475 var window_descriptor: ?u8 = null;