blob: 59c7552d3775fcbf5ecaee1d41c4a04c7fc59b24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
use crate::result::ArchiveResult;
use crate::utils::ReadHelper;
use std::io::{Read, Write};
pub trait ArchiveDatatype<const SIZE: usize>: Sized {
const SIZE: usize = SIZE;
fn parse(buf: [u8; SIZE]) -> Self;
fn dump(&self) -> [u8; SIZE];
fn read(mut reader: impl Read) -> ArchiveResult<Self> {
Ok(Self::parse(reader.read2buf::<SIZE>()?))
}
fn write(&self, mut writer: impl Write) -> ArchiveResult<()> {
writer.write(&self.dump())?;
Ok(())
}
}
|