Skip to content

Commit 45e71b5

Browse files
committed
implement Write and Read for BufFile
1 parent 83a5080 commit 45e71b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ impl<const MAGIC: u64, const VERSION: u16> DerefMut for BinFile<MAGIC, VERSION>
5050
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
5151
}
5252

53+
impl<const MAGIC: u64, const VERSION: u16> Read for BinFile<MAGIC, VERSION> {
54+
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { self.0.read(buf) }
55+
}
56+
57+
impl<const MAGIC: u64, const VERSION: u16> Write for BinFile<MAGIC, VERSION> {
58+
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) }
59+
fn flush(&mut self) -> io::Result<()> { self.0.flush() }
60+
}
61+
5362
impl<const MAGIC: u64, const VERSION: u16> BinFile<MAGIC, VERSION> {
5463
/// The magical byte octet, taken from the generic parameter of the type. It must be a big
5564
/// endian-serialized octet.

0 commit comments

Comments
 (0)