You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking into why a #[musli(packed)] struct Point3 { x: f32, y: f32, z: f32 } was so small when it was all-zeros despite setting the integer encoding to fixed length, and I discovered that ALL fields in packed structs use variable length int encoding. You can't turn it off by choosing fixed length integers in your musli-wire Encoding. Since musli-wire implements packed using musli-storage, I would have thought it would just pass the variable/fixed-ness down to that. But it doesn't:
Of course you may not consider this a bug. Packed structs are supposed to be small, gotta save space for only 62 bytes, etc.
For making the behaviour optional, you could add type params to Encoding specifically for ints and lengths in a packed struct. To avoid breaking changes to people's formats, the type parameters could default to Variable. And then you would pass these down to the StorageEncoder/Decoder instead of always passing Variable.
The text was updated successfully, but these errors were encountered:
I was looking into why a
#[musli(packed)] struct Point3 { x: f32, y: f32, z: f32 }
was so small when it was all-zeros despite setting the integer encoding to fixed length, and I discovered that ALL fields in packed structs use variable length int encoding. You can't turn it off by choosing fixed length integers in your musli-wire Encoding. Since musli-wire implements packed using musli-storage, I would have thought it would just pass the variable/fixed-ness down to that. But it doesn't:musli/crates/musli-wire/src/en.rs
Line 397 in be09b1f
This was introduced in 7a3c387
Of course you may not consider this a bug. Packed structs are supposed to be small, gotta save space for only 62 bytes, etc.
For making the behaviour optional, you could add type params to Encoding specifically for ints and lengths in a packed struct. To avoid breaking changes to people's formats, the type parameters could default to
Variable
. And then you would pass these down to the StorageEncoder/Decoder instead of always passing Variable.The text was updated successfully, but these errors were encountered: