Replies: 1 comment
-
assuming there are multiple kinds of properties with different values, we could save some work no matter what approach we take by adding generics. i.e. struct PropertyImpl<V> {
size: u64,
field_1: String,
// ...
// if fields are also tied to values somehow (i'm not familiar with gvas), additional generics or a trait + associated type could turn it into:
// fields: <V as SomeTrait>::Fields,
separator: u8,
values: V,
} In general though, there's more than one way to skin a cat here. binrw does not currently have a mechanism for getting the serialized lengths of values, but here's a few ways I came up with off the top of my head that you could use to proceed:
All of these approaches have their own tradeoffs, and maybe I'm making bad assumptions about the format, because I'm not familiar with gvas. For instance, if the value of |
Beta Was this translation helpful? Give feedback.
-
I'm writing a reader/writer for a format similar to unreal engine's
gvas
save files.Each property in the save file has a format that can be (heavily) simplified to something like.
When writing and working with these properties I don't want to manually specify the size, or implement
BinWrite
by hand.Something similar to
#[bw(calc = size_of(Type1) + size_of(Type2))] size: u64
sounds ideal to me, but any insights and feedback would be appreciated.Beta Was this translation helpful? Give feedback.
All reactions