Closed
Description
Use Case
I am working on a high-throughput IO project reading/writing fixed size blocks to disk. I have a broadly used compilation parameter for the block id size.
I have a struct like the following:
#[derive(FromBytes, FromZeroes, AsBytes, Unaligned)]
#[repr(packed)]
pub struct IndexEntryFlags(u8);
bitflags! {
impl IndexEntryFlags: u8 {
const NONE = 0b00;
const DELETE = 0b01;
}
}
#[derive(FromBytes, FromZeroes, AsBytes, Unaligned)]
#[repr(packed)]
pub struct IndexEntry<const SIZE_BLOCK_ID: usize> {
block_number: U64,
flags: IndexEntryFlags,
block_id: [u8; SIZE_BLOCK_ID]
}
Problem
This generates an error:
error[E0793]: reference to packed field is unaligned
... even though the exact same compilation works with:
...
block_id: [u8; 32]
...
Request
Support generic constants in fixed size arrays for AsBytes
.