frame_header

Function frame_header 

Source
pub fn frame_header(buf: &[u8]) -> ([u8; 13], usize)
Expand description

Return an array which contains the crc and varint for a given buffer, and a usize that is the length of the provided array which corresponds to the valid varint and crc. Returns an array instead of a Vec to avoid allocations.

ยงExamples

use crc_frame::frame_header;

let buf = b"12345";

let (header_buf, header_len) = frame_header(buf);

let mut out = vec![];
out.extend_from_slice(&header_buf[..header_len]);
out.extend_from_slice(buf);