From 3615adac4760f27f00818fd380df892b4efda6a4 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 17 Oct 2022 19:23:45 -0400 Subject: [PATCH] Switch from bitfield-struct to modular-bitfield --- Cargo.lock | 40 ++++++++++++++++++++++++++++------------ Cargo.toml | 2 +- src/index.rs | 17 ++++++----------- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66ccdee..390fe9d 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,17 +55,6 @@ dependencies = [ "syn", ] -[[package]] -name = "bitfield-struct" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0baacb7d5b6e94369201d5807e086d3f36e2bd35057ca2c5a680af3737e35fa" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -415,6 +404,27 @@ dependencies = [ "autocfg", ] +[[package]] +name = "modular-bitfield" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a53d79ba8304ac1c4f9eb3b9d281f21f7be9d4626f72ce7df4ad8fbde4f38a74" +dependencies = [ + "modular-bitfield-impl", + "static_assertions", +] + +[[package]] +name = "modular-bitfield-impl" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a7d5f7076603ebc68de2dc6a650ec331a062a13abaa346975be747bbfa4b789" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -469,7 +479,6 @@ name = "physis" version = "0.1.0" dependencies = [ "binrw", - "bitfield-struct", "bitflags", "crc", "criterion", @@ -478,6 +487,7 @@ dependencies = [ "hard-xml", "hmac-sha512", "libz-sys", + "modular-bitfield", "paste", "serde", "serde_json", @@ -635,6 +645,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "syn" version = "1.0.102" diff --git a/Cargo.toml b/Cargo.toml index 363eba2..f6f6b01 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ binrw = "0.10" libz-sys = { version = "1.1", default-features = false } # nice to have features rust is lacking at the moment -bitfield-struct = "0.1" +modular-bitfield = "0.11" paste = "1" # needed for half-float support which FFXIV uses in it's model data diff --git a/src/index.rs b/src/index.rs index 5baee1c..34cc953 100755 --- a/src/index.rs +++ b/src/index.rs @@ -1,6 +1,6 @@ use binrw::binrw; use binrw::BinRead; -use bitfield_struct::bitfield; +use modular_bitfield::prelude::*; use std::io::SeekFrom; #[binrw] @@ -31,18 +31,13 @@ pub struct SqPackIndexHeader { index_data_size: u32, } -#[bitfield(u32)] +#[bitfield] #[binrw] -#[br(map = | x: u32 | Self::from(x))] +#[br(map = Self::from_bytes)] pub struct IndexHashBitfield { - #[bits(1)] - pub size: u32, - - #[bits(3)] - pub data_file_id: u32, - - #[bits(28)] - pub offset: u32, + pub size: B1, + pub data_file_id: B3, + pub offset: B28, } #[binrw]