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

Copy bytes from src to dst, injecting the MSBs stored in a separate byte at the end of src.

Panics

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

Examples

use resol_vbus::utils::copy_bytes_injecting_septett;

let src = &[ 0x07, 0x01, 0x4c, 0x00, 0x00, 0x02, 0x01, 0x7f, 0x00, 0x05, 0x38, 0x22, 0x76, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 ];
let mut dst = [0u8; 16];

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

assert_eq!(&[ 0x07, 0x01, 0x4c, 0x00, 0x82, 0x01, 0xff, 0x00, 0xb8, 0x22, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00 ], &dst);