jam1garner / binrw

A Rust crate for helping parse and rebuild binary data using ✨macro magic✨.
https://binrw.rs
MIT License
620 stars 36 forks source link

Get actual size beforehand #262

Closed NefixEstrada closed 5 months ago

NefixEstrada commented 5 months ago

Hello!

Is it possible to know the size that will have a struct beforehand?

So, having,

#[binrw]
struct A {
  first: u8,
  second: u16,
  third: u8,
}

Is it possible to know that the size that the struct will have will be 4 at comptime?

Could also be added as #[brw(calc(SOMETHING))] for another struct? Or the struct itself?

Thank you!