From: Kostya Shishkov Date: Fri, 26 May 2017 05:34:39 +0000 (+0200) Subject: more utility code X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=96c6be977343471ee20e442bee42d93949421451;p=nihav.git more utility code --- diff --git a/src/io/byteio.rs b/src/io/byteio.rs index 9fee3bd..497e8cc 100644 --- a/src/io/byteio.rs +++ b/src/io/byteio.rs @@ -190,6 +190,16 @@ impl<'a> ByteReader<'a> { pub fn is_eof(&mut self) -> bool { self.io.is_eof() } + + pub fn size(&mut self) -> i64 { + self.io.size() + } + + pub fn left(&mut self) -> i64 { + let size = self.io.size(); + if size == -1 { return -1; } + return size - (self.io.tell() as i64) + } } impl<'a> MemoryReader<'a> {