Function cobs_simd::cobs_encode_to

source ·
pub fn cobs_encode_to(input: &[u8], output: &mut [u8], method: Method) -> usize
Expand description

COBS-encode data to a buffer.

User must ensure that the buffer is big enough. Actual buffer usage depends on input, but always fits within encoded_size_upper_bound(input.len()).

Example

use cobs_simd::{cobs_encode_to, encoded_size_upper_bound, Method};

let input_data = [1, 3, 0, 7, 0, 8];
let mut encoded_output = vec![0; encoded_size_upper_bound(input_data.len())];
let output_length = cobs_encode_to(&input_data, &mut encoded_output, Method::StdSimd32TwoStage);
encoded_output.truncate(output_length);