D-Bus Versus Varlink
Lawrence D'Oliveiro
ldo at geek-central.gen.nz
Tue Apr 2 22:06:04 UTC 2024
Lennart Poettering wrote:
> Suitable to streaming large amount of data (i.e. useful for listing
> larger directories of things, where the dbus broker would normally
> kick you off the bus)
There is a solution to this, which takes slightly more work: open a
pipe or socketpair, and exchange one end with the peer by passing a
value of the Unix file descriptor type. Then you can do the bulk
transfer without going through the D-Bus daemon.
> * JSON sucks for large integers.
Surely this is a limitation of the existing libraries, not that of the
JSON protocol itself. E.g. this works in Python:
import json
d = json.loads("{\"key\" : 18446744073709551616}")
print(d, d["key"] + 1)
Output:
{'key': 18446744073709551616} 18446744073709551617
If you don’t want your JSON library to require support for
multiprecision integers, then at least it needs to provide an
intermediate representation as a simple array of decimal digits (plus
sign, if present), with conversions available to/from standard C
types--signed/unsigned int/long, with errors returned if the
representation won’t fit. If the application needs more than that, then
it can explicitly link against a multiprecision integer library.
Looking at how JavaScript itself deals with this
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON>,
receiving high-precision integers is a little fiddly, but doable.
More information about the dbus
mailing list