Run clippy autofix and fmt
This commit is contained in:
parent
6b436b7af2
commit
fe745be3e3
15 changed files with 36 additions and 43 deletions
|
@ -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]
|
||||
|
|
|
@ -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<dyn std::error::Error>> {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<SetEntry>,
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue