Expand description
Marshalling values to and from the D-Bus wire format.
Two rules account for nearly all of the difficulty:
-
Every value is padded to its natural alignment, and the offset that alignment is measured against is the start of the message, not the start of the value being written. An encoder therefore has to carry a position, not just a buffer. (The body may be encoded from zero, because it always begins on an 8-byte boundary and every alignment divides 8.)
-
The bytes carry no type tags. A
u32on the wire is four bytes and nothing else; only the signature says what it is. Decoding is therefore signature-directed, and a signature that disagrees with the bytes yields silent nonsense rather than an error — which is whyDecoderbounds- checks every read instead of trusting lengths from the peer.
The exception is v, a variant, which carries its own signature inline.
BlueZ wraps every property in one, so most real payloads are variants all
the way down.
Structs§
- Decoder
- Reads values, signature-directed, bounds-checking every access.
- Encoder
- Writes values in little-endian, tracking position so padding is correct.
Enums§
- Codec
Error - A malformed or unexpected message.