Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Structs are encoded w/ map type but are not valid msgpack maps! #40

@drbawb

Description

@drbawb

I've been doing interop with other msgpack libraries this weekend, namely the official msgpack-javascript.

The problem is that we currently call _emit_map_len() before encoding a Rust struct into the stream.
This pops the msgpack type fixmap (0x8<len>) onto the stream.

However when encoding struct fields we only encode the value of the field, which means this is not a valid msgpack map entry.

I have a fix for this over on my fork (though it's written on top of PR #39): feature/fix-struct-interop

The fix involves emitting the field-name when encoding; and reading/checking the field-name when decoding.


Again this only affects non-Rust readers: as they are expecting a map-key where one is not present. In my experience this means the fixmap is decoded into a single key (containing all the bytes of the struct) and then the rest of the stream is corrupted.

Would such a fix be welcome? Though it changes the semantics of how we're encoding structs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions