Function xsnappy::encode [−][src]
pub fn encode(dst: &mut [u8], src: &[u8]) -> usize
Encode src
to dst
. The dst
must be initialized with a certain length.
Return the exact length of encoded data.
Examples:
use xsnappy::{max_encode_len, encode}; let mut src = b"hello world! hello world!"; let mut dst = vec![0; max_encode_len(src.len())]; let len = encode(&mut dst, src); dst.resize(len, 0); // resize to exact length
Panics:
Panics if the length of dst
is less then max_encode_len(src.len())