use std::fs::File;
use std::io::{self, Read, Seek, Write};
pub struct ReadFile(File);
impl ReadFile {
pub(crate) fn new(file: File) -> Self {
Self(file)
}
}
impl Read for ReadFile {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.0.read(buf)
}
}
impl Seek for ReadFile {
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
self.0.seek(pos)
}
}
pub struct WriteFile(File);
impl WriteFile {
pub(crate) fn new(file: File) -> Self {
Self(file)
}
}
impl Write for WriteFile {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.0.write(buf)
}
fn flush(&mut self) -> io::Result<()> {
self.0.flush()
}
}
impl Seek for WriteFile {
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
self.0.seek(pos)
}
}