From 105920555a40eb6e3b65c77e69a8b3ab5dbaecbb Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 24 Jan 2025 00:04:35 -0800 Subject: [PATCH] rust: Use std::io instead of deku::no_std_io --- rust/src/unity/types/binary.rs | 2 +- rust/src/unity/types/common.rs | 10 +++++----- rust/src/unity/util.rs | 2 +- rust/src/wow/db.rs | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/rust/src/unity/types/binary.rs b/rust/src/unity/types/binary.rs index 046bca39b..73faf3cf1 100644 --- a/rust/src/unity/types/binary.rs +++ b/rust/src/unity/types/binary.rs @@ -222,7 +222,7 @@ pub struct ByteArray { } impl<'a, Ctx> DekuReader<'a, Ctx> for ByteArray where Ctx: Copy { - fn from_reader_with_ctx(reader: &mut Reader, _ctx: Ctx) -> Result { + fn from_reader_with_ctx(reader: &mut Reader, _ctx: Ctx) -> Result { let count = i32::from_reader_with_ctx(reader, ())? as usize; let mut buf = vec![0x00; count]; reader.read_bytes(count, &mut buf)?; diff --git a/rust/src/unity/types/common.rs b/rust/src/unity/types/common.rs index 910d29984..250db4e42 100644 --- a/rust/src/unity/types/common.rs +++ b/rust/src/unity/types/common.rs @@ -29,7 +29,7 @@ fn check_count(count: usize, limit: usize) -> Result<(), DekuError> { } impl<'a, T, Ctx> DekuReader<'a, Ctx> for UnityArray where T: DekuReader<'a, Ctx>, Ctx: Clone { - fn from_reader_with_ctx(reader: &mut Reader, ctx: Ctx) -> Result { + fn from_reader_with_ctx(reader: &mut Reader, ctx: Ctx) -> Result { let count = i32::from_reader_with_ctx(reader, ())? as usize; let mut values = Vec::new(); for _ in 0..count { @@ -56,7 +56,7 @@ pub struct Map { impl<'a, K, V, Ctx> DekuReader<'a, Ctx> for Map where K: DekuReader<'a, Ctx>, V: DekuReader<'a, Ctx>, Ctx: Clone { - fn from_reader_with_ctx(reader: &mut Reader, ctx: Ctx) -> Result { + fn from_reader_with_ctx(reader: &mut Reader, ctx: Ctx) -> Result { let count = i32::from_reader_with_ctx(reader, ())?; let mut keys = Vec::new(); let mut values = Vec::new(); @@ -199,7 +199,7 @@ pub struct Matrix4x4 { pub e3: Vec4, } -fn unpack_i32s(reader: &mut Reader, num_items: usize, bit_size: usize) -> Result, DekuError> { +fn unpack_i32s(reader: &mut Reader, num_items: usize, bit_size: usize) -> Result, DekuError> { let mut result = Vec::new(); for _ in 0..num_items { let value = i32::from_reader_with_ctx(reader, BitSize(bit_size))?; @@ -220,7 +220,7 @@ impl From for Vec { } impl<'a, Ctx> DekuReader<'a, Ctx> for Packedi32Vec where Ctx: Clone { - fn from_reader_with_ctx(reader: &mut Reader, _ctx: Ctx) -> Result { + fn from_reader_with_ctx(reader: &mut Reader, _ctx: Ctx) -> Result { let num_items = u32::from_reader_with_ctx(reader, ())? as usize; let byte_array_count = u32::from_reader_with_ctx(reader, ())? as usize; reader.seek(SeekFrom::Current(byte_array_count as i64)).unwrap(); @@ -248,7 +248,7 @@ impl From for Vec { } impl<'a, Ctx> DekuReader<'a, Ctx> for Packedf32Vec where Ctx: Clone { - fn from_reader_with_ctx(reader: &mut Reader, _ctx: Ctx) -> Result { + fn from_reader_with_ctx(reader: &mut Reader, _ctx: Ctx) -> Result { let num_items = u32::from_reader_with_ctx(reader, ())?; let scale = f32::from_reader_with_ctx(reader, ())?; let start = f32::from_reader_with_ctx(reader, ())?; diff --git a/rust/src/unity/util.rs b/rust/src/unity/util.rs index 662891f6d..c403a2ed3 100644 --- a/rust/src/unity/util.rs +++ b/rust/src/unity/util.rs @@ -1,7 +1,7 @@ use deku::prelude::*; use std::fmt::Debug; -pub fn deku_peek<'a, T, R: deku::no_std_io::Read + deku::no_std_io::Seek>(reader: &mut Reader, msg: &str) -> Result +pub fn deku_peek<'a, T, R: std::io::Read + std::io::Seek>(reader: &mut Reader, msg: &str) -> Result where for<'b> T: DekuReader<'b, ()> + Debug { println!("deku_peek - {}", msg); diff --git a/rust/src/wow/db.rs b/rust/src/wow/db.rs index c87e90432..b24d76f0f 100644 --- a/rust/src/wow/db.rs +++ b/rust/src/wow/db.rs @@ -136,7 +136,7 @@ fn from_u32(v: u32) -> Result T::from_reader_with_ctx(&mut reader, ()) } -fn read_field_to_u32(reader: &mut Reader, field_offset_bits: usize, field_size_bits: usize) -> Result { +fn read_field_to_u32(reader: &mut Reader, field_offset_bits: usize, field_size_bits: usize) -> Result { // Assumes the reader points to the start of the record let old = reader.seek(std::io::SeekFrom::Current(0)) .map_err(|err| DekuError::Io(err.kind()))?; @@ -176,7 +176,7 @@ impl Wdc4Db2File { } } - pub fn read_vec<'a, T, R: deku::no_std_io::Read + deku::no_std_io::Seek>(&self, reader: &mut Reader, field_number: usize) -> Result, DekuError> + pub fn read_vec<'a, T, R: std::io::Read + std::io::Seek>(&self, reader: &mut Reader, field_number: usize) -> Result, DekuError> where for<'b> T: DekuReader<'b, ()> { let field_offset = self.field_storage_info[field_number].field_offset_bits as usize; @@ -196,7 +196,7 @@ impl Wdc4Db2File { Ok(result) } - pub fn read_string_helper<'a, R: deku::no_std_io::Read + deku::no_std_io::Seek>(&self, reader: &mut Reader, string_offset: u32) -> Result { + pub fn read_string_helper<'a, R: std::io::Read + std::io::Seek>(&self, reader: &mut Reader, string_offset: u32) -> Result { let mut string = String::new(); let old = reader.seek(std::io::SeekFrom::Current(0)) .map_err(|err| DekuError::Io(err.kind()))?; @@ -219,7 +219,7 @@ impl Wdc4Db2File { Ok(string) } - pub fn read_string_direct<'a, R: deku::no_std_io::Read + deku::no_std_io::Seek>(&self, reader: &mut Reader, field_number: usize, extra_offset: usize) -> Result { + pub fn read_string_direct<'a, R: std::io::Read + std::io::Seek>(&self, reader: &mut Reader, field_number: usize, extra_offset: usize) -> Result { let field_offset = (self.field_storage_info[field_number].field_offset_bits as usize) + (extra_offset * 8); let old = reader.seek(std::io::SeekFrom::Current(0)) .map_err(|err| DekuError::Io(err.kind()))?; @@ -231,12 +231,12 @@ impl Wdc4Db2File { v } - pub fn read_string<'a, R: deku::no_std_io::Read + deku::no_std_io::Seek>(&self, reader: &mut Reader, field_number: usize) -> Result { + pub fn read_string<'a, R: std::io::Read + std::io::Seek>(&self, reader: &mut Reader, field_number: usize) -> Result { let string_offset = self.read_field::(reader, field_number)?; self.read_string_helper(reader, string_offset) } - pub fn read_field<'a, T, R: deku::no_std_io::Read + deku::no_std_io::Seek>(&self, reader: &mut Reader, field_number: usize) -> Result + pub fn read_field<'a, T, R: std::io::Read + std::io::Seek>(&self, reader: &mut Reader, field_number: usize) -> Result where for<'b> T: DekuReader<'b, ()> { let field_offset = self.field_storage_info[field_number].field_offset_bits as usize;