diff --git a/sqlite-compress/src/functions/header.rs b/sqlite-compress/src/functions/header.rs index 2a26aaf..416a984 100644 --- a/sqlite-compress/src/functions/header.rs +++ b/sqlite-compress/src/functions/header.rs @@ -28,10 +28,12 @@ impl TryFrom for CodecKind { pub struct Header { /// Version of the prefix format understood by this decoder. pub version: u8, - /// Compression algorithm used for the payload. - pub codec: u8, /// Number of bytes occupied by the full prefix, including future fields. pub header_len: u8, + /// Compression algorithm used for the payload. + pub codec: u8, + /// Explicit padding to ensure 4-byte alignment. + pub padding: u8, /// Dictionary used for compression; zero denotes a raw Zstandard payload. pub dict_id: U32, /// Original byte length used to bound decompression output. @@ -54,8 +56,9 @@ impl Header { pub fn new(dict_id: DictId, uncompressed_len: u32) -> Self { Self { version: Self::VERSION, - codec: CodecKind::Zstd as u8, header_len: Self::PREFIX_SIZE as u8, + codec: CodecKind::Zstd as u8, + padding: 0, dict_id: U32::new(dict_id.get()), uncompressed_len: U32::new(uncompressed_len), } diff --git a/sqlite-compress/tests/dict_train.rs b/sqlite-compress/tests/dict_train.rs index 4ac7744..7ba29fa 100644 --- a/sqlite-compress/tests/dict_train.rs +++ b/sqlite-compress/tests/dict_train.rs @@ -33,7 +33,7 @@ pub fn decompress_blob(state: &ExtensionState, blob: &[u8]) -> Vec { } pub fn header_dict_id(blob: &[u8]) -> u32 { - u32::from_le_bytes(blob[3..7].try_into().expect("framed header")) + u32::from_le_bytes(blob[4..8].try_into().expect("framed header")) } #[test]