pub fn stuffing_required(data: &[u8]) -> usize {
	let mut state = 0;
	let mut count = 0;
	for &byte in data {
		if byte == PATTERN[state] {
			state += 1;
		} else {
			state = 0;
		}
		if state == 3 {
			state = 0;
			count += 1;
		}
	}

	count
}
/// Calculate the amount of stuffing bytes required for specific data.
Calculate the amount of stuffing bytes required for specific data.
Calculate the amount of stuffing bytes required for specific data .
pub fn stuffing_required(data: &[u8]) -> usize {
	let mut state = 0;
	let mut count = 0;
	for &byte in data {
		if byte == PATTERN[state] {
			state += 1;
		} else {
			state = 0;
		}
		if state == 3 {
			state = 0;
			count += 1;
		}
	}
	count
}
pub fn stuffing_required ( data : & [ u8 ] ) -> usize { let mut state = 0 ; let mut count = 0 ; for & byte in data { if byte == PATTERN [ state ] { state += 1 ; } else { state = 0 ; } if state == 3 { state = 0 ; count += 1 ; } } count }
Calculate the amount of stuffing bytes required for specific data.
Calculate the amount of stuffing bytes required for specific data .
data
&[u8]
data
&[u8]