[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-dbus
Subject:    Re: D-Bus Versus Varlink
From:       Lawrence D'Oliveiro <ldo () geek-central ! gen ! nz>
Date:       2024-04-02 22:06:04
Message-ID: 20240403110604.11b5d653 () theon ! geek-central ! gen ! nz
[Download RAW message or body]

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.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic