zero_formatter/util.rs
1use error::*;
2use formatter::*;
3
4use std::io::Seek;
5use byteorder::{ReadBytesExt, WriteBytesExt};
6
7pub fn check_non_null<R>(r: &mut R, offset: &mut u64) -> ZeroFormatterResult<i32>
8 where R: Seek + ReadBytesExt + WriteBytesExt + Formatter<i32> {
9 r.deserialize(offset)
10 .and_then(|bs| if bs >= 0 {
11 Ok(bs)
12 } else {
13 ZeroFormatterError::invalid_binary(*offset)
14 })
15}