| ... | @@ -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 decompressed | 104 | /// contains a checksum that does not match the checksum of the decompressed |
| 105 | /// data | 105 | /// data |
| 106 | /// - `error.ReservedBitSet` if the reserved bit of the frame header is set | 106 | /// - `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 frame | 107 | /// - `error.EndOfStream` if `src` does not contain a complete frame |
| 109 | /// - an error in `block.Error` if there are errors decoding a block | 108 | /// - an error in `block.Error` if there are errors decoding a block |
| 110 | /// - `error.SkippableSizeTooLarge` if the frame is skippable and reports a | 109 | /// - `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 decompressed | 152 | /// contains a checksum that does not match the checksum of the decompressed |
| 154 | /// data | 153 | /// data |
| 155 | /// - `error.ReservedBitSet` if the reserved bit of the frame header is set | 154 | /// - `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 frame | 155 | /// - `error.EndOfStream` if `src` does not contain a complete frame |
| 158 | /// - `error.OutOfMemory` if `allocator` cannot allocate enough memory | 156 | /// - `error.OutOfMemory` if `allocator` cannot allocate enough memory |
| 159 | /// - an error in `block.Error` if there are errors decoding a block | 157 | /// - 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; |
| 196 | | 195 | |
| 197 | /// Decode a Zstandard frame from `src` into `dest`, returning the number of | 196 | /// 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 decompressed | 207 | /// contains a checksum that does not match the checksum of the decompressed |
| 209 | /// data | 208 | /// data |
| 210 | /// - `error.ReservedBitSet` if the reserved bit of the frame header is set | 209 | /// - `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 frame | 210 | /// - `error.EndOfStream` if `src` does not contain a complete frame |
| 213 | /// - an error in `block.Error` if there are errors decoding a block | 211 | /// - an error in `block.Error` if there are errors decoding a block |
| 214 | /// - `error.BadContentSize` if the content size declared by the frame does | 212 | /// - `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 decompressed | 323 | /// contains a checksum that does not match the checksum of the decompressed |
| 326 | /// data | 324 | /// data |
| 327 | /// - `error.ReservedBitSet` if the reserved bit of the frame header is set | 325 | /// - `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 frame | 326 | /// - `error.EndOfStream` if `src` does not contain a complete frame |
| 330 | /// - `error.OutOfMemory` if `allocator` cannot allocate enough memory | 327 | /// - `error.OutOfMemory` if `allocator` cannot allocate enough memory |
| 331 | /// - an error in `block.Error` if there are errors decoding a block | 328 | /// - 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 | } |
| 467 | | 464 | |
| 468 | const 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 set | 468 | /// - `error.ReservedBitSet` if the reserved bits of the header are set |
| 474 | /// - `error.EndOfStream` if `source` does not contain a complete header | 469 | /// - `error.EndOfStream` if `source` does not contain a complete header |
| 475 | pub fn decodeZstandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)!frame.Zstandard.Header { | 470 | pub 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()); |
| 477 | | 472 | |
| 478 | if (descriptor.unused) return error.UnusedBitSet; | | |
| 479 | if (descriptor.reserved) return error.ReservedBitSet; | 473 | if (descriptor.reserved) return error.ReservedBitSet; |
| 480 | | 474 | |
| 481 | var window_descriptor: ?u8 = null; | 475 | var window_descriptor: ?u8 = null; |