Get the uncompressed size from the header without decompressing.
(data: &[u8])
| 70 | |
| 71 | /// Get the uncompressed size from the header without decompressing. |
| 72 | pub fn uncompressed_size(data: &[u8]) -> Result<usize, CodecError> { |
| 73 | if data.len() < HEADER_SIZE { |
| 74 | return Err(CodecError::Truncated { |
| 75 | expected: HEADER_SIZE, |
| 76 | actual: data.len(), |
| 77 | }); |
| 78 | } |
| 79 | Ok(u32::from_le_bytes([data[0], data[1], data[2], data[3]]) as usize) |
| 80 | } |
| 81 | |
| 82 | /// Get the compression level from the header. |
| 83 | pub fn compression_level(data: &[u8]) -> Result<i32, CodecError> { |