Function copy_bytes_extracting_septett

Source
pub fn copy_bytes_extracting_septett(dst: &mut [u8], src: &[u8])
Expand description

Copy bytes from src to dst, extracting the MSB into a separate byte and appending it at the end of dst.

§Panics

The function panics if the dst slice is not exactly one byte longer than the src slice.

§Examples

use resol_vbus::utils::copy_bytes_extracting_septett;

let src = &[ 0x07, 0x01, 0x4c, 0x00, 0x82, 0x01, 0xff, 0x00, 0xb8, 0x22, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00 ];
let mut dst = [0u8; 20];

copy_bytes_extracting_septett(&mut dst [0..5], &src [0..4]);
copy_bytes_extracting_septett(&mut dst [5..10], &src [4..8]);
copy_bytes_extracting_septett(&mut dst [10..15], &src [8..12]);
copy_bytes_extracting_septett(&mut dst [15..20], &src [12..16]);

assert_eq!(&[ 0x07, 0x01, 0x4c, 0x00, 0x00, 0x02, 0x01, 0x7f, 0x00, 0x05, 0x38, 0x22, 0x76, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 ], &dst);