jam1garner / binrw

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

Get actual size beforehand #262

Closed NefixEstrada closed 1 month ago

NefixEstrada commented 1 month 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!