#[derive(SizedData)]
Expand description
Derives the SizedData
trait for structs.
§Implementation Details
The macro generates a size()
implementation that:
- Sums the sizes of all fields using their
SizedData
implementations - Works with named fields, tuple structs, and unit structs
§Example Generated Code
struct UserAccount {
authority: Pubkey,
counter: u64,
}
impl SizedData for UserAccount {
fn size() -> usize {
<Pubkey as SizedData>::size() +
<u64 as SizedData>::size()
}
}
§Panics
Panics if used on enums or unions - only structs are supported.