| ... | ... | @@ -104,7 +104,6 @@ pub fn decodeAlloc( |
| 104 | 104 | /// contains a checksum that does not match the checksum of the decompressed |
| 105 | 105 | /// data |
| 106 | 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 | 107 | /// - `error.EndOfStream` if `src` does not contain a complete frame |
| 109 | 108 | /// - an error in `block.Error` if there are errors decoding a block |
| 110 | 109 | /// - `error.SkippableSizeTooLarge` if the frame is skippable and reports a |
| ... | ... | @@ -153,7 +152,6 @@ pub const DecodedFrame = union(enum) { |
| 153 | 152 | /// contains a checksum that does not match the checksum of the decompressed |
| 154 | 153 | /// data |
| 155 | 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 | 155 | /// - `error.EndOfStream` if `src` does not contain a complete frame |
| 158 | 156 | /// - `error.OutOfMemory` if `allocator` cannot allocate enough memory |
| 159 | 157 | /// - an error in `block.Error` if there are errors decoding a block |
| ... | ... | @@ -192,7 +190,8 @@ const FrameError = error{ |
| 192 | 190 | ChecksumFailure, |
| 193 | 191 | BadContentSize, |
| 194 | 192 | EndOfStream, |
| 195 | | } || InvalidBit || block.Error; |
| 193 | ReservedBitSet, |
| 194 | } || block.Error; |
| 196 | 195 | |
| 197 | 196 | /// Decode a Zstandard frame from `src` into `dest`, returning the number of |
| 198 | 197 | /// bytes read from `src` and written to `dest`. The first four bytes of `src` |
| ... | ... | @@ -208,7 +207,6 @@ const FrameError = error{ |
| 208 | 207 | /// contains a checksum that does not match the checksum of the decompressed |
| 209 | 208 | /// data |
| 210 | 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 | 210 | /// - `error.EndOfStream` if `src` does not contain a complete frame |
| 213 | 211 | /// - an error in `block.Error` if there are errors decoding a block |
| 214 | 212 | /// - `error.BadContentSize` if the content size declared by the frame does |
| ... | ... | @@ -325,7 +323,6 @@ pub const FrameContext = struct { |
| 325 | 323 | /// contains a checksum that does not match the checksum of the decompressed |
| 326 | 324 | /// data |
| 327 | 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 | 326 | /// - `error.EndOfStream` if `src` does not contain a complete frame |
| 330 | 327 | /// - `error.OutOfMemory` if `allocator` cannot allocate enough memory |
| 331 | 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 | 462 | } else return header.content_size; |
| 466 | 463 | } |
| 467 | 464 | |
| 468 | | const InvalidBit = error{ UnusedBitSet, ReservedBitSet }; |
| 469 | 465 | /// Decode the header of a Zstandard frame. |
| 470 | 466 | /// |
| 471 | 467 | /// Errors returned: |
| 472 | | /// - `error.UnusedBitSet` if the unused bits of the header are set |
| 473 | 468 | /// - `error.ReservedBitSet` if the reserved bits of the header are set |
| 474 | 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 | 471 | const descriptor = @bitCast(frame.Zstandard.Header.Descriptor, try source.readByte()); |
| 477 | 472 | |
| 478 | | if (descriptor.unused) return error.UnusedBitSet; |
| 479 | 473 | if (descriptor.reserved) return error.ReservedBitSet; |
| 480 | 474 | |
| 481 | 475 | var window_descriptor: ?u8 = null; |