Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently in Tauri's ipc it is passed in
JSON
format, which can cause some problems.Number overflow
Since JSON doesn't support
BigInt
, JavaScript'sNumber
doesn't represent numbers in Rust well, e.g.u64
,u128
etc.u64::MAX =
18446744073709551615
, But in JavaScript we get18446744073709552000
, To pass it safely, we have to convert it to String, which is not a good solution.Binary data
JSON doesn't support passing Bytes, currently Tauri converts it to a
JSON Array
, which I think adds some overhead.For example if I want to pass a Vec as binary data, I convert it to
String
viabase64
and then decode it toUint8Array
in JavaScript, and even then it's faster than Array.Tauri 2.0.0-alpha.11
I've noticed that the new version of tauri supports passing binary data directly to the corresponding
ArrayBuffer
, which is great, now we have unlimited possibilities.tauri/examples/commands/main.rs
Lines 220 to 224 in af3268a
But does this mean we have to manually convert
struct
toVec<u8>
and parseArrayBuffer
in Javascript?If we only have a single value, this is perfectly fine, if we have multiple values, we have to manually serialise and deserialise?
Consider the following code:
My thoughts
JSON is great in most cases, but in some cases it doesn't meet our needs, and passing
Response
directly is very efficient, but not convenient for developers.We can write a new
RJON
(Rust JavaScript Object Notation) to replace JSON.Datetime
UUID
A simple example:
We can now pass these values better
Bad
We have to implement
RJON
serialisation and deserialisation in both Rust and JavaScript, which adds some work, and adds some size (which should be small) since JSON is built-in in JavaScript andRJON
is not.Other
It would also be nice to allow
custom
IPC to bypass JSON.Beta Was this translation helpful? Give feedback.
All reactions