streamvbyte

Crates.iostreamvbyte
lib.rsstreamvbyte
version0.1.1
sourcesrc
created_at2020-08-30 05:06:15.606931
updated_at2020-08-30 05:09:28.13808
descriptionRust FFI bindings for streamvbyte
homepage
repositoryhttps://github.com/mpetri/streamvbyte
max_upload_size
id282557
size25,356
Matthias Petri (mpetri)

documentation

README

streamvbyte

Rust FFI bindings to streamvbyte: https://github.com/lemire/streamvbyte

Examples

Encode an u32 slice into a new buf in with encode:

use streamvbyte::encode;
let out_bytes: Vec<u8> = encode(&[1,2,44,5123,43,534]);

...or by using the encode_to_buf function into an existing buffer:

use streamvbyte::{max_compressedbytes,encode_to_buf};
let input = vec![1,2,44,5123,43,534];
let max_bytes = max_compressedbytes(input.len());
let mut out_buf = vec![0;max_bytes];
let bytes_written = encode_to_buf(&input,&mut out_buf);
assert_eq!(bytes_written.unwrap(),10);

You can use encode_delta to encode increasing sequences more effectively:

use streamvbyte::encode_delta;
let out_bytes: Vec<u8> = encode_delta(&[1,2,44,64,71,534],0);

Decoding values works in much the same way:

use streamvbyte::{decode_delta,encode_delta};
let out_bytes: Vec<u8> = encode_delta(&[1,2,44,64,71,534],0);
let mut recovered = vec![0;6];
let bytes_read = decode_delta(&out_bytes,&mut recovered,0);
assert_eq!(out_bytes.len(),bytes_read);
assert_eq!(&recovered,&[1,2,44,64,71,534]);
Commit count: 5

cargo fmt