diff --git a/below/store/Cargo.toml b/below/store/Cargo.toml index 27256ec2..cce92894 100644 --- a/below/store/Cargo.toml +++ b/below/store/Cargo.toml @@ -11,7 +11,7 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.75" -bitflags = "1.3" +bitflags = "2.4" bytes = { version = "1.1", features = ["serde"] } common = { package = "below-common", version = "0.7.1", path = "../common" } humantime = "2.1" diff --git a/below/store/src/lib.rs b/below/store/src/lib.rs index 5b3b58e5..d2b40045 100644 --- a/below/store/src/lib.rs +++ b/below/store/src/lib.rs @@ -94,6 +94,7 @@ pub const MAX_CHUNK_COMPRESS_SIZE: u32 = 1 << MAX_CHUNK_COMPRESS_SIZE_PO2; const_assert_eq!(MAX_CHUNK_COMPRESS_SIZE, 32768); bitflags! { + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] struct IndexEntryFlags: u32 { /// If set, data item is compressed with zstd. const COMPRESSED = 0x1; @@ -122,7 +123,7 @@ bitflags! { impl IndexEntryFlags { fn get_chunk_compress_size_po2(&self) -> u32 { - (self.bits & Self::CHUNK_COMPRESS_SIZE_PO2.bits) >> CHUNK_COMPRESS_SHIFT + (self.bits() & Self::CHUNK_COMPRESS_SIZE_PO2.bits()) >> CHUNK_COMPRESS_SHIFT } fn set_chunk_compress_size_po2(&mut self, chunk_compress_size_po2: u32) -> Result<()> { @@ -132,7 +133,7 @@ impl IndexEntryFlags { MAX_CHUNK_COMPRESS_SIZE_PO2 ); } - self.bits |= chunk_compress_size_po2 << CHUNK_COMPRESS_SHIFT; + *self |= IndexEntryFlags::from_bits_retain(chunk_compress_size_po2 << CHUNK_COMPRESS_SHIFT); Ok(()) } }