GVariant: say that serialized form needs an out-of-band length
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 19 Sep 2014 14:05:04 +0000 (15:05 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 19 Sep 2014 15:58:23 +0000 (16:58 +0100)
commit7db1baf59078c667ac1ae43f839b2b1866e65a87
treef8d1be4b12e92b02bbf890880441d966b764cbdb
parent174ebaefcc2b1b94f4a628e60f150b7209230dbf
GVariant: say that serialized form needs an out-of-band length

This confused me for a while, because it isn't the same as D-Bus.
Like GVariant, the D-Bus serialization needs an out-of-band
endianness and type indicator, but unlike GVariant, serialized
D-Bus objects encapsulate their own length (often by starting with
a byte-count). This does come at some redundancy cost, so I can see
why the more efficient GVariant format does this the way it does;
but it's a difference between D-Bus and GVariant that seems worth
calling out.

It's also relevant for the designers of file or message-framing
formats: with D-Bus serialization it would be feasible to say "the file
starts with a little-endian D-Bus variant, followed by...",
but in GVariant you wouldn't be able to deserialize the variant
unless you either assume that it extends to end-of-file, or have
an explicit length.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=736975
Reviewed-by: Ryan Lortie
glib/gvariant.c