Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer fails to deserialize with serde and binary formats #40

Open
hinto-janai opened this issue Apr 23, 2023 · 0 comments · May be fixed by #41
Open

Buffer fails to deserialize with serde and binary formats #40

hinto-janai opened this issue Apr 23, 2023 · 0 comments · May be fixed by #41

Comments

@hinto-janai
Copy link

hinto-janai commented Apr 23, 2023

The Buffer type will always fail to deserialize when using it with serde and binary formats, the ones I've tested:

To reproduce (num-format v0.4.4 + bincode v1.3.3):

fn main() {
    // Create an empty `Buffer`.
    let mut buf = num_format::Buffer::new();

    // Serialize to bytes.
    let ser: Vec<u8> = bincode::serialize(&buf).unwrap();

    // Attempt to deserialize. This panics.
    let de: num_format::Buffer = bincode::deserialize(&ser).unwrap();
}

Error message:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("invalid type: byte array, expected bytes of maximum length 191")', src/main.rs:7:70

Culprit code is most likely here.

Regular formats (JSON, TOML, etc) will (de)serialize correctly, so I believe it has something to do with the binary formats and the custom serde implementation on Buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant