mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-04 00:21:57 +00:00
Added io::{Read, Seek, Write} impl for opened drv files.
This commit is contained in:
parent
69236ca742
commit
a349a81d51
@ -275,3 +275,27 @@ pub struct OpenFile<'a, T> {
|
||||
/// Inner
|
||||
inner: IoCursor<T>,
|
||||
}
|
||||
|
||||
impl<'a, T: io::Seek + io::Read> io::Read for OpenFile<'a, T> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
self.inner.read(buf)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: io::Seek> io::Seek for OpenFile<'a, T> {
|
||||
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
|
||||
// TODO: Allow file to expand beyond here too.
|
||||
self.inner.seek(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: io::Seek + io::Write> io::Write for OpenFile<'a, T> {
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
// TODO: Allow file to expand beyond
|
||||
self.inner.write(buf)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
self.inner.flush()
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ impl<T: Write + Seek> Write for IoCursor<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Read + Seek> Seek for IoCursor<T> {
|
||||
impl<T: Seek> Seek for IoCursor<T> {
|
||||
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
|
||||
match pos {
|
||||
SeekFrom::Start(pos) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user