Function rscache::parse::be_u32_smart [−][src]
Expand description
Reads 2 bytes if the first byte <= -1 after calculations, reads 4 bytes otherwise.
Errors
Parser can reach EOF early if not enough bytes are supplied.
Example
use rscache::parse::be_u32_smart;
let buffer = &[255, 54, 2, 0, 62, 1, 42, 233];
let (buffer, value1) = be_u32_smart(buffer)?;
let (buffer, value2) = be_u32_smart(buffer)?;
assert_eq!(value1, 2134245888);
assert_eq!(value2, 15873);
assert_eq!(buffer, &[42, 233]);