aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2021-10-20 18:26:46 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2021-10-20 18:26:46 +0200
commitdee2d2f1b9a9b17593db0e9affdbb588ac72aa4e (patch)
treea49beb873d09f4b41708111ae571234195d5a732
parenta91a83670604f3799b48c240591c9354ed9b3a6b (diff)
downloadnihav-dee2d2f1b9a9b17593db0e9affdbb588ac72aa4e.tar.gz
core/io: add the finish() and new_read_boxed() to FileReader
-rw-r--r--nihav-core/src/io/byteio.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/nihav-core/src/io/byteio.rs b/nihav-core/src/io/byteio.rs
index a194e65..3fbee94 100644
--- a/nihav-core/src/io/byteio.rs
+++ b/nihav-core/src/io/byteio.rs
@@ -557,6 +557,12 @@ impl<T: Read+Seek> FileReader<T> {
pub fn new_read(file: T) -> Self {
FileReader { file: Box::new(file), eof : false }
}
+ /// Constructs a new instance of `FileReader` using a boxed resource.
+ pub fn new_read_boxed(file: Box<T>) -> Self {
+ FileReader { file, eof : false }
+ }
+ /// Destroys the reader and releases the reader resource for a further use.
+ pub fn finish(self) -> Box<T> { self.file }
}
impl<T: Read+Seek> ByteIO for FileReader<T> {