Function byte::check_len [−][src]
pub fn check_len(bytes: &[u8], len: usize) -> Result<usize>
A helper function that checks whether the given length
exceeded the length of slice; return Err(Error::Incomplete) if not.
Example
use byte::*; let bytes = [0u8; 4]; assert_eq!(check_len(&bytes, 4), Ok(4)); assert_eq!(check_len(&bytes, 5), Err(Error::Incomplete));