Skip to content

Output does not work with other existing tools #18

Open
@computermouth

Description

@computermouth

I checked out another person's branch, from PR #16 . It solves the nightly compilation issues, and completes without a problem.

However, writing out the payload, and checking it with external tools, I encountered some errors.

    let stdout = io::stdout();
    let mut handle = stdout.lock();

    handle.write_all(&buf).unwrap();
    handle.flush().unwrap();
$ cargo +nightly run > out.mp
serialized 49 bytes

$ mpk msgpacker.mp --to-json
"Kuala Lumpur"

$ ~/go/bin/msgpack-cli decode msgpacker.mp --pp
"Kuala Lumpur"2025/03/13 16:48:48 msgpack decode error [pos 14]: invalid byte descriptor for decoding bytes, got: 0x82

Given that the test clears internally when you parse back in, I have a feeling that the library maybe doesn't implement the spec correctly. This is backed up by rmp and rmp_serde parsing cleanly with the tools.

$ ~/go/bin/msgpack-cli decode rmp-serde.mp --pp
["Kuala Lumpur",{"Street 1":10,"Street 2":20},["Zone 1","Zone 2"]]

$ ~/go/bin/msgpack-cli decode msgpacker.mp --pp
"Kuala Lumpur"2025/03/13 17:06:38 msgpack decode error [pos 14]: invalid byte descriptor for decoding bytes, got: 0x82

$ mpk rmp-serde.mp --to-json
["Kuala Lumpur",{"Street 2":20,"Street 1":10},["Zone 1","Zone 2"]]

$ mpk msgpacker.mp --to-json
"Kuala Lumpur"

Here's the difference in the hex:

$ xxd msgpacker.mp 
00000000: ac4b 7561 6c61 204c 756d 7075 7282 a853  .Kuala Lumpur..S
00000010: 7472 6565 7420 3214 a853 7472 6565 7420  treet 2..Street 
00000020: 310a 92a6 5a6f 6e65 2031 a65a 6f6e 6520  1...Zone 1.Zone 
00000030: 32                                       2

$ xxd rmp-serde.mp 
00000000: 93ac 4b75 616c 6120 4c75 6d70 7572 82a8  ..Kuala Lumpur..
00000010: 5374 7265 6574 2032 14a8 5374 7265 6574  Street 2..Street
00000020: 2031 0a92 a65a 6f6e 6520 31a6 5a6f 6e65   1...Zone 1.Zone
00000030: 2032                                      2

The rmp-serde.mp file starts with a byte 0x93. According to the spec, this is a fixed array delimiter with 3 elements (name, inhabitants_per_street, and zones). It seems these other tools expect the payload to start with either an array, map, or otherwise exclusively contain a single messagepack type -- opposed to this library's list of types with no outer container at the top level

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions