summaryrefslogtreecommitdiff
path: root/shared/src/helper.rs
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/helper.rs')
-rw-r--r--shared/src/helper.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/shared/src/helper.rs b/shared/src/helper.rs
index 873c9d8..d6fbe66 100644
--- a/shared/src/helper.rs
+++ b/shared/src/helper.rs
@@ -180,6 +180,27 @@ impl ReadWrite for Vec<[u32; 3]> {
.collect())
}
}
+impl ReadWrite for Vec<[u32; 4]> {
+ fn write(&self, w: &mut dyn Write) -> Result<()> {
+ for e in self {
+ w.write_all(&e[0].to_le_bytes())?;
+ w.write_all(&e[1].to_le_bytes())?;
+ w.write_all(&e[2].to_le_bytes())?;
+ w.write_all(&e[3].to_le_bytes())?;
+ }
+ Ok(())
+ }
+ fn read(r: &mut dyn Read) -> Result<Self> {
+ let mut buf = Vec::new();
+ r.read_to_end(&mut buf)?;
+ Ok(buf
+ .into_iter()
+ .array_chunks::<{ size_of::<u32>() }>()
+ .map(u32::from_le_bytes)
+ .array_chunks::<4>()
+ .collect())
+ }
+}
impl ReadWrite for Vec<[u16; 4]> {
fn write(&self, w: &mut dyn Write) -> Result<()> {
for e in self {