New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usize does not work well for de/serialization. #12
Comments
I don't think its absolutely necessary to use
I don't but it shouldn't be hard to write some code that trims all usizes to u32s (unless you are using really large graphs that should be no problem) and then serializes the FastGraph in some 32bit compatible way? @dabreegster any ideas about this? |
I actually hit this problem a few days ago and hacked around it like this: dabreegster@21d95f6. As long as you don't have more than 2^32 nodes or edges or values for weight, this works fine. An alternative would be using Option in lots of places to represent invalid cases. This is a bit less memory efficient, which might matter in something performance-sensitive like fast_paths. I haven't benchmarked that yet. Even with Option, there would be problems if something bigger than 2^32 was serialized, then read back in wasm32. If nobody has use cases for more than 2**32 yet, my vote is to go for the quick change and document the limitation. |
Ok so you just changed the special values
I understand |
Right, so I don't think it's worth doing this.
There are places in the code that do something like
|
WASM is 32bit always (afaik).
So if you serialize a FastGraph on a 64bit platform the resulting bytes will not be deserializable in a WASM binary.
Is there a real need for
usize
or would you be amenable to a more concrete type? Or do you know of some way to tell serde thatusize
should read 8 bytes (u64
) when it's decoding into au32
?The text was updated successfully, but these errors were encountered: