Function varint_simd::encode

source ·
pub fn encode<T: VarIntTarget>(num: T) -> ([u8; 16], u8)
Available with target feature sse2 only.
Expand description

Encodes a single number to a varint. Requires SSE2 support.

Produces a tuple, with the encoded data followed by the number of bytes used to encode the varint.

Examples

use varint_simd::encode;

let encoded = encode::<u32>(1337);
assert_eq!(encoded, ([185, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2));