Closed jerzakm closed 1 year ago
Do you have an API example in mind of how the binary format would be represented and used if exposed?
What if it was similar to the existing parseText
?
import { Jomini } from "jomini";
const data = // binary data, read from autosave.v3 for example
const parser = await Jomini.initialize();
variant 1 - everything happens in 1 step. Binary to js object
const out = parser.parseBinary(data);
variant 2 - 2 steps. First binary to text, then text to js object
const text = parser.parseBinary(data);
//or
const text = parser.binaryToText(data);
//or - consistent with rakaly naming
const text = parser.meltBinary(data);
const out = parser.parseText(data);
binaryToText
might be the clearest one, I think parseBinary
implies that the save gets parsed all the way like in variant 1.
I'm not super familiar with Rust and wasm binding gotchas when it comes to this stuff, so please don't spend too much time on something like this on my account :) If it requires more than adding simple bindings then maybe this is the excuse I needed to finally dip more into rust-world.
The biggest hurdle is that many keys of binary objects are numbers. The number->string key mapping changes per game and per patch and paradox said no last time I asked if I could release this map. So in order to implement melting, the api would need to accept a user supplied map, which seems like a pretty big hurdle. So I've been wary of adding it with a big caveat
I wasn't aware of the binary mapping issue, thanks for explaining. I think I'll just hack in rakaly-cli
and call it good enough for now.
Sounds good, let me know if there's more I can do to assist.
Do you plan to maybe add bindings for parsing binary files? Autosaves for some (all?) games are forced into binary format and it'd be very convenient to not have to manually use the rust lib.