3Hren / 3Hren/msgpack-rust

`String` successfully parses bytes buffer

Open
#363 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.4k
Forks
162
PR merge metrics
No merged PRs in 30d

Description

I have a pre-existing msgpack schema that I tried to encode in rmp-serde like this:

```
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
#[serde(untagged)]
pub enum Value {
Numeric(f32),
String(String),
#[serde(with = "serde_bytes")]
Bytes(Vec),
Bool(bool),
}
```

However, if I use `rmp-serde` to decode a buffer that happens to contain valid utf-8, like

```
{
"m": "set",
"path": "ui-state",
"value": {
"type": "Buffer",
"data": [
97
]
}
}
```

(base64 `g6Fto3NldKRwYXRoqHVpLXN0YXRlpXZhbHVlxAFh`), I get a `String`, but I actually wanted a `Bytes`. It would be nice if there were some sort of strictness annotation that would make this behave as intended.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.