diff --git a/src/array_property.rs b/src/array_property.rs index f767875..3fc63f9 100644 --- a/src/array_property.rs +++ b/src/array_property.rs @@ -21,7 +21,7 @@ fn calculate_header_size(key_name: &str, array_key_data: &ArrayKeyData) -> u64 { impl crate::structs::PropertyBase for ArrayProperty { fn type_name() -> &'static str { - return "ArrayProperty"; + "ArrayProperty" } fn size_in_bytes(&self) -> u32 { @@ -29,7 +29,7 @@ impl crate::structs::PropertyBase for ArrayProperty { 4 + 8 + crate::common::size_of_string_with_length(&self.key_name) + calc_key_data_size_in_bytes(&self.key_data) - + calc_size_in_bytes(&self) + + calc_size_in_bytes(self) } } @@ -83,9 +83,7 @@ fn calc_size_in_bytes(prop: &ArrayProperty) -> u32 { for entry in &prop.entries { size += match &entry.key { - ArrayValue::Struct { r#struct } => { - crate::struct_property::calc_size_in_bytes(&r#struct) - } + ArrayValue::Struct { r#struct } => crate::struct_property::calc_size_in_bytes(r#struct), ArrayValue::String(string_map_key) => { crate::common::size_of_string_with_length(&string_map_key.value) } @@ -120,20 +118,20 @@ pub enum ArrayKeyData { } fn calc_key_data_size_in_bytes(key_data: &ArrayKeyData) -> u32 { - return match key_data { + match key_data { ArrayKeyData::String() => 0, ArrayKeyData::Struct { name, type_name, struct_name, } => { - crate::common::size_of_string_with_length(&name) - + crate::common::size_of_string_with_length(&type_name) - + crate::common::size_of_string_with_length(&struct_name) + crate::common::size_of_string_with_length(name) + + crate::common::size_of_string_with_length(type_name) + + crate::common::size_of_string_with_length(struct_name) + 8 + 17 } - }; + } } #[binrw] diff --git a/src/bin/ireko.rs b/src/bin/ireko.rs index a288fe8..255b51c 100644 --- a/src/bin/ireko.rs +++ b/src/bin/ireko.rs @@ -1,9 +1,7 @@ use binrw::BinRead; -use flate2::Decompress; -use flate2::bufread::ZlibDecoder; -use ireko::{CompressedSaveFile, TaggedSerialization}; +use ireko::CompressedSaveFile; use std::env; -use std::io::{Cursor, Read}; +use std::io::Cursor; fn main() -> Result<(), Box> { let args: Vec = env::args().collect(); diff --git a/src/bool_property.rs b/src/bool_property.rs index 7f62668..5b4ada5 100644 --- a/src/bool_property.rs +++ b/src/bool_property.rs @@ -12,7 +12,7 @@ pub struct BoolProperty { impl crate::structs::PropertyBase for BoolProperty { fn type_name() -> &'static str { - return "IntProperty"; + "IntProperty" } fn size_in_bytes(&self) -> u32 { diff --git a/src/build_data.rs b/src/build_data.rs index 3338055..9b7f764 100644 --- a/src/build_data.rs +++ b/src/build_data.rs @@ -1,4 +1,3 @@ -use crate::common::{read_string_with_length, write_string_with_length}; use crate::str_property::StrProperty; use crate::structs::PropertyBase; use crate::structs::{ @@ -29,8 +28,8 @@ pub struct DABuildDataStruct { #[cfg(test)] mod tests { use super::*; - use binrw::{BinRead, BinWrite}; - use std::{fs::write, io::Cursor}; + use binrw::BinRead; + use std::io::Cursor; #[test] fn read_build_data() { diff --git a/src/enum_property.rs b/src/enum_property.rs index b669ee4..606995e 100644 --- a/src/enum_property.rs +++ b/src/enum_property.rs @@ -17,7 +17,7 @@ pub struct EnumProperty { impl crate::structs::PropertyBase for EnumProperty { fn type_name() -> &'static str { - return "EnumProperty"; + "EnumProperty" } fn size_in_bytes(&self) -> u32 { @@ -30,7 +30,7 @@ impl crate::structs::PropertyBase for EnumProperty { #[cfg(test)] mod tests { use super::*; - use binrw::{BinRead, BinWrite}; + use binrw::BinRead; use std::io::Cursor; #[test] diff --git a/src/float_property.rs b/src/float_property.rs index 4e844fb..5c8c0b1 100644 --- a/src/float_property.rs +++ b/src/float_property.rs @@ -11,7 +11,7 @@ pub struct FloatProperty { impl crate::structs::PropertyBase for FloatProperty { fn type_name() -> &'static str { - return "FloatProperty"; + "FloatProperty" } fn size_in_bytes(&self) -> u32 { diff --git a/src/guid.rs b/src/guid.rs index bf18c06..5a902f8 100644 --- a/src/guid.rs +++ b/src/guid.rs @@ -12,11 +12,11 @@ pub struct Guid { impl crate::structs::PropertyBase for Guid { fn type_name() -> &'static str { - return "StructProperty"; + "StructProperty" } fn struct_name() -> Option<&'static str> { - return Some("Guid"); + Some("Guid") } fn size_in_bytes(&self) -> u32 { diff --git a/src/int_property.rs b/src/int_property.rs index b2c32b1..9dd8953 100644 --- a/src/int_property.rs +++ b/src/int_property.rs @@ -11,7 +11,7 @@ pub struct IntProperty { impl crate::structs::PropertyBase for IntProperty { fn type_name() -> &'static str { - return "IntProperty"; + "IntProperty" } fn size_in_bytes(&self) -> u32 { diff --git a/src/linear_color.rs b/src/linear_color.rs index 01ebcda..5af000a 100644 --- a/src/linear_color.rs +++ b/src/linear_color.rs @@ -11,11 +11,11 @@ pub struct LinearColorStruct { impl crate::structs::PropertyBase for LinearColorStruct { fn type_name() -> &'static str { - return "StructProperty"; + "StructProperty" } fn struct_name() -> Option<&'static str> { - return Some("LinearColor"); + Some("LinearColor") } fn size_in_bytes(&self) -> u32 { diff --git a/src/map_property.rs b/src/map_property.rs index cf319a6..c0e4e79 100644 --- a/src/map_property.rs +++ b/src/map_property.rs @@ -2,7 +2,7 @@ use crate::common::{ read_bool_from, read_string_with_length, write_bool_as, write_string_with_length, }; use crate::guid::Guid; -use crate::struct_property::{Struct, calc_size_in_bytes}; +use crate::struct_property::Struct; use crate::structs::{GenericProperty, PropertyBase}; use binrw::{BinRead, BinResult, binrw}; @@ -265,7 +265,7 @@ fn calc_entry_size_in_bytes(prop: &MapProperty) -> u32 { #[binrw] #[derive(Debug)] pub struct MapProperty { - #[bw(calc = calc_entry_size_in_bytes(&self))] + #[bw(calc = calc_entry_size_in_bytes(self))] pub size_in_bytes: u32, #[brw(pad_before = 4)] @@ -287,7 +287,7 @@ pub struct MapProperty { impl crate::structs::PropertyBase for MapProperty { fn type_name() -> &'static str { - return "MapProperty"; + "MapProperty" } fn size_in_bytes(&self) -> u32 { @@ -296,7 +296,7 @@ impl crate::structs::PropertyBase for MapProperty { + crate::common::size_of_string_with_length(&self.value_name) + 5 + 4 - + calc_entry_size_in_bytes(&self) + + calc_entry_size_in_bytes(self) } } diff --git a/src/name_property.rs b/src/name_property.rs index a0845ed..f771240 100644 --- a/src/name_property.rs +++ b/src/name_property.rs @@ -16,7 +16,7 @@ pub struct NameProperty { impl crate::structs::PropertyBase for NameProperty { fn type_name() -> &'static str { - return "NameProperty"; + "NameProperty" } fn size_in_bytes(&self) -> u32 { diff --git a/src/set_property.rs b/src/set_property.rs index ddd3e06..60bdab6 100644 --- a/src/set_property.rs +++ b/src/set_property.rs @@ -1,6 +1,5 @@ use crate::common::{read_string_with_length, write_string_with_length}; use crate::map_property::{KeyType, MapSubStrProperty}; -use crate::struct_property::Struct; use crate::structs::GenericProperty; use binrw::{BinRead, BinResult, binrw}; @@ -77,7 +76,7 @@ pub struct SetProperty { #[brw(pad_before = 5)] pub key_type: KeyType, - #[br(parse_with = custom_parser, args(size_in_bytes, &key_name, &name))] + #[br(parse_with = custom_parser, args(size_in_bytes, &key_name, name))] pub entries: Vec, } diff --git a/src/str_property.rs b/src/str_property.rs index 269fe75..90fce2a 100644 --- a/src/str_property.rs +++ b/src/str_property.rs @@ -16,7 +16,7 @@ pub struct StrProperty { impl crate::structs::PropertyBase for StrProperty { fn type_name() -> &'static str { - return "StrProperty"; + "StrProperty" } fn size_in_bytes(&self) -> u32 { diff --git a/src/struct_property.rs b/src/struct_property.rs index 85d7564..4b331e5 100644 --- a/src/struct_property.rs +++ b/src/struct_property.rs @@ -62,7 +62,7 @@ pub enum Struct { pub(crate) fn calc_size_in_bytes(r#struct: &Struct) -> u32 { // todo - return match r#struct { + match r#struct { Struct::DateTime(date_time_struct) => date_time_struct.size_in_bytes(), Struct::DALoadOption(daload_option_struct) => daload_option_struct.size_in_bytes(), Struct::SaveSlotInfo(save_slot_info_struct) => save_slot_info_struct.size_in_bytes(), @@ -98,7 +98,7 @@ pub(crate) fn calc_size_in_bytes(r#struct: &Struct) -> u32 { Struct::Transform(transform_struct) => transform_struct.size_in_bytes(), Struct::Quat(quat_struct) => quat_struct.size_in_bytes(), Struct::Vector(vector_struct) => vector_struct.size_in_bytes(), - }; + } } #[binrw] diff --git a/src/structs.rs b/src/structs.rs index e334dd3..2c65cf8 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -11,7 +11,6 @@ use crate::linear_color::LinearColorStruct; use crate::map_property::MapProperty; use crate::name_property::NameProperty; use crate::primary_asset_id::PrimaryAssetIdStruct; -use crate::primary_asset_type::PrimaryAssetTypeStruct; use crate::str_property::StrProperty; use binrw::{BinRead, BinResult, BinWrite, binrw}; use std::fmt::Debug; @@ -359,11 +358,11 @@ pub(crate) trait PropertyBase { impl PropertyBase for DateTimeStruct { fn type_name() -> &'static str { - return "StructProperty"; + "StructProperty" } fn struct_name() -> Option<&'static str> { - return Some("DateTime"); + Some("DateTime") } fn size_in_bytes(&self) -> u32 { @@ -373,11 +372,11 @@ impl PropertyBase for DateTimeStruct { impl PropertyBase for VectorStruct { fn type_name() -> &'static str { - return "StructProperty"; + "StructProperty" } fn struct_name() -> Option<&'static str> { - return Some("Vector"); + Some("Vector") } fn size_in_bytes(&self) -> u32 { @@ -387,11 +386,11 @@ impl PropertyBase for VectorStruct { impl PropertyBase for QuatStruct { fn type_name() -> &'static str { - return "StructProperty"; + "StructProperty" } fn struct_name() -> Option<&'static str> { - return Some("Quat"); + Some("Quat") } fn size_in_bytes(&self) -> u32 {