From 96c6be977343471ee20e442bee42d93949421451 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 26 May 2017 07:34:39 +0200 Subject: [PATCH] more utility code --- src/io/byteio.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) 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> { -- 2.39.5