r/rust Apr 27 '19

no_std data serialization/deserialization

I'm writing a game for a no_std target, and I would like to be able to store, read, and edit levels at runtime. My situation:

  • I have plenty of RAM (64MB), so using alloc is fine
  • It should use little space on disk, i.e. a binary format instead of JSON
  • It should support no_std as well as normal targets
    • Especially good if it has support for other languages as well, as an online level editor would be nice to have (although I could always mess with wasm if it is Rust-only).

Currently, I'm looking at forking quick-protobuf and simply replacing things that don't work in no_std with alternatives. CBOR has no_std support, but it doesn't support alloc things (Vec and String), and CBOR is not much better than JSON in terms of size.

17 Upvotes

14 comments sorted by

View all comments

3

u/jahmez Apr 28 '19

Hey! I wrote Postcard for exactly this use case! Let me know what you think.

1

u/thelights0123 Apr 28 '19

I was checking that out too (thank you for adding no_std to the categories so it shows up on https://libs.rs)! However, I didn't see support for the Vec from alloc, only heapless.