karolherbst , Englisch
@karolherbst@chaos.social avatar

anyway, some 🦀 content today:

I'm considering using serde in rusticl, however my use case is not to parse arbitrary data, but always structs with no custom data allowed. In short: the struct defines the data layout.

And we have some helpers in mesa dealing with reading/writing data to a blob.

So I'm wondering if a custom serde serialize/deserializer is what I want, or if I want something more special/focused as serde seems to be too generic for my use case here.

decathorpe ,
@decathorpe@mastodon.social avatar

@karolherbst if you don't need to be generic over different data types, writing your own derive macro might be the solution that produces the most efficient code ... /me hides

matt ,

@karolherbst I think you'd probably be better off with something more focused. serde tries to support both human-readable formats like JSON and efficient binary formats, but the code that it generates for the latter is sometimes not as efficient as it could be, particularly for enums.

When you say "And we have some helpers in mesa dealing with reading/writing data to a blob", do you mean you already have helpers for that in Rust, or only in C so far?

karolherbst OP ,
@karolherbst@chaos.social avatar

@matt it's C code and we use it for e.g. serializing GPU shaders so it can be stored in a shader cache. But it's all manual serialization and deserialization code, it's just mostly there to deal with alignment, padding and buffer overruns (like you can check if the buffer used for reading/writing wasn't big enough and handle it).

So, because writing the code yourself is annoying I was wondering if something can take a struct and generate the code for me in rust.

refi64 ,
@refi64@refi64.social avatar

@karolherbst @matt
Depending on the exact constraints & whether or not you're tied to existing data formats, this almost sounds like a use case for something more like bytemuck's Pod types or rkyv?

  • Alle
  • Abonniert
  • Moderiert
  • Favoriten
  • random
  • haupteingang
  • Alle Magazine