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

Unknown length error with rpm-serde. #15

Closed
TimonPost opened this issue Feb 9, 2020 · 2 comments · Fixed by #21
Closed

Unknown length error with rpm-serde. #15

TimonPost opened this issue Feb 9, 2020 · 2 comments · Fixed by #21

Comments

@TimonPost
Copy link
Member

TimonPost commented Feb 9, 2020

I use rmp-serde crate for serialisation. When I perform the difference serialisation I get the error

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: UnknownLength'

If a None value is passed to serialized_seq rmp-serde throws this error. See:

https://github.com/3Hren/msgpack-rust/blob/master/rmp-serde/src/encode.rs#L516

This is what serde-diff does:
https://github.com/amethyst/serde-diff/blob/master/src/lib.rs#L403

When serde-diff calls unwrap() this will throw an error. Though with bincode it won't panic.

use serde_diff::{Apply, Diff, SerdeDiff, FieldPathMode, Config};
use serde::{Serialize, Deserialize};

#[derive(SerdeDiff, Serialize, Deserialize, PartialEq, Debug)]
struct TestStruct {
    a: u32,
    b: f64,
}

fn main () {
    let old = TestStruct {
        a: 5,
        b: 2.,
    };
    let new = TestStruct {
        a: 8, // Differs from old.a, will be serialized
        b: 2.,
    };

    let diff = Config::new()
        .with_field_path_mode(FieldPathMode::Index)
        .serializable_diff(&old, &new);

    let msgpack_data = rmp_serde::to_vec(&diff).unwrap();
//    let bincode_data = bincode::serialize(&diff).unwrap();
}
@kabergstrom
Copy link
Collaborator

@kabergstrom
Copy link
Collaborator

The underlying issues seem to be fixed upstream now: 3Hren/msgpack-rust#257

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.

2 participants