forked from fast-pack/FastPFOR-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteger_codec.rs
More file actions
39 lines (36 loc) · 1.27 KB
/
Copy pathinteger_codec.rs
File metadata and controls
39 lines (36 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use std::io::Cursor;
use crate::rust::FastPForResult;
/// Integer compression/decompression interface with length headers.
///
/// Implementations write output length as a header before compressed data,
/// enabling self-describing compressed streams.
pub trait Integer<T> {
/// Compresses integers with length header.
///
/// # Arguments
/// * `input_length` - Number of integers to compress
/// * `input_offset` - Read position cursor, advanced by `input_length`
/// * `output_offset` - Write position cursor, advanced by bytes written
fn compress(
&mut self,
input: &[u32],
input_length: u32,
input_offset: &mut Cursor<u32>,
output: &mut [T],
output_offset: &mut Cursor<u32>,
) -> FastPForResult<()>;
/// Decompresses integers using length header.
///
/// # Arguments
/// * `input_length` - Total compressed data length
/// * `input_offset` - Read position cursor, advanced by bytes read
/// * `output_offset` - Write position cursor, advanced by integers written
fn uncompress(
&mut self,
input: &[T],
input_length: u32,
input_offset: &mut Cursor<u32>,
output: &mut [u32],
output_offset: &mut Cursor<u32>,
) -> FastPForResult<()>;
}