shekohex / allo-isolate

Run Multithreaded Rust along with Dart VM (in isolate) 🌀
Apache License 2.0
120 stars 18 forks source link

Feat/UUID #30

Closed Roms1383 closed 2 years ago

Roms1383 commented 2 years ago

In the same fashion, this PR adds support for uuid crate, since it's widely used in app and web alike. I'm gonna keep as Draft until it's implemented downstream on flutter_rust_bridge (please hold on for a while, previous PR for chrono types is almost finished but not quite yet).

Roms1383 commented 2 years ago

Leaving link to experiment in the playground as a reminder, mostly to myself ^^

Roms1383 commented 2 years ago

Also, something I'm not familiar in FFI / Rust / Dart contexts is if endianness matters or if this is already taken care of. So, should I explicitly settle on little or big endian, and if yes, which one would you recommend ?

Roms1383 commented 2 years ago

What is interesting is that we can also "pack" a Vec<uuid::Uuid> into a single Vec<u8> and be able to reconstruct it on both sides :

Roms1383 commented 2 years ago

Also, something I'm not familiar in FFI / Rust / Dart contexts is if endianness matters or if this is already taken care of. So, should I explicitly settle on little or big endian, and if yes, which one would you recommend ?

I could also adjust to the system, using Endianness on Dart side and cpu_endian on Rust side, what do you think ?

shekohex commented 2 years ago

Also, something I'm not familiar in FFI / Rust / Dart contexts is if endianness matters or if this is already taken care of. So, should I explicitly settle on little or big endian, and if yes, which one would you recommend ?

I could also adjust to the system, using Endianness on Dart side and cpu_endian on Rust side, what do you think ?

I do think it does not matter that much, you better stick with just one on both sides, the other option is use the native endianness (in rust you use *_to_ne_bytes() for example). Nonetheless, you will declare it in the docs and with an example too.

Roms1383 commented 2 years ago

I do think it does not matter that much, you better stick with just one on both sides, the other option is use the native endianness (in rust you use *_to_ne_bytes() for example). Nonetheless, you will declare it in the docs and with an example too.

I made a quick bench locally to check whether there's a big delta in performance when using native endianness and it doesn't seem to make any notable difference (~2%). I cannot test on different machines with different endianness so I guess you're right, it can probably be ignored.

Roms1383 commented 2 years ago

I think it's ready for review 👌

shekohex commented 2 years ago

There will be a bit of delay to publish this version now on crates.io since I'm on Mobile right now, but once I've my laptop I will issue a new release.

Thank you!

Roms1383 commented 2 years ago

Thanks Shady, no worries ! We're almost good downstream too ^^