[][src]Function streamvbyte::encode_delta_to_buf

pub fn encode_delta_to_buf(
    input: &[u32],
    output: &mut [u8],
    initial: u32
) -> Result<usize, StreamVbyteError>

Encode a sequence non decreasing of u32 integers into a vbyte encoded byte representation into an existing buffer output.

Arguments

  • input - The input sequence of non decreasing u32 integers
  • output - The output u8 slice of at least max_compressedbytes
  • initial - The intial value to substract from the all the value in the array to decrease the universe. MUST be <= input[0]

Required: output buf is at least max_compressedbytes long.

Examples

use streamvbyte::{max_compressedbytes,encode_delta_to_buf};
let input = vec![1,2,44,54,433,534];
let max_bytes = max_compressedbytes(input.len());
let mut out_buf = vec![0;max_bytes];
let bytes_written = encode_delta_to_buf(&input,&mut out_buf,0);
assert_eq!(bytes_written.unwrap(),9);

Return

Returns the number of bytes written to output during encoding