Function byte::check_len
[−]
[src]
pub fn check_len(bytes: &[u8], len: usize) -> Result<usize>
A shorthand function to check whether the given length
exceeded the length of slice; return Err(Error::Incomplete)
if not.
Usually used in implementation of TryRead
and TryWrite
.
Example
use byte::*; let bytes = [0u8; 4]; assert_eq!(check_len(&bytes, 4), Ok(4)); assert_eq!(check_len(&bytes, 5), Err(Error::Incomplete));