From: Kostya Shishkov Date: Wed, 20 Oct 2021 16:26:46 +0000 (+0200) Subject: core/io: add the finish() and new_read_boxed() to FileReader X-Git-Url: https://git.nihav.org/?p=nihav.git;a=commitdiff_plain;h=dee2d2f1b9a9b17593db0e9affdbb588ac72aa4e core/io: add the finish() and new_read_boxed() to FileReader --- 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 FileReader { 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) -> Self { + FileReader { file, eof : false } + } + /// Destroys the reader and releases the reader resource for a further use. + pub fn finish(self) -> Box { self.file } } impl ByteIO for FileReader {