write_frame_into

Function write_frame_into 

Source
pub fn write_frame_into<W: Write>(writer: W, buf: &[u8]) -> Result<usize>
Expand description

Write a crc’d frame into the provided Write instance. Returns the number of bytes written in total, including the varint size and crc. This is always equivalent to a std::io::Write::write_all call due to the impossibility to write partial frames.

§Examples

use crc_frame::{write_frame_into, parse_frame};

let data = b"12345";

let mut buf = vec![];

write_frame_into(&mut buf, data).unwrap();

let (begin, end) = parse_frame(&buf).unwrap();

assert_eq!(&buf[begin..end], data);