Skip to content

Id128 has broken compact serde implementation #78

@vilgotf

Description

@vilgotf

Adding the following test shows it clearly:

    #[test]
    fn test_ser_de() {
        let id = Id128::parse_str("1071334a-9324-4511-adcc-b8d8b70eb1c2").unwrap();

        assert_tokens(
            &id.readable(),
            &[Token::Str("1071334a93244511adccb8d8b70eb1c2")],
        );

        // expected bytes but serialized as Str
        /*assert_tokens(
            &id.compact(),
            &[Token::Bytes(&[
                16, 113, 51, 74, 147, 36, 69, 17, 173, 204, 184, 216, 183, 14, 177, 194,
            ])],
        );/*

        // invalid type string, expected bytes
        /*assert_tokens(
            &id.compact(),
            &[Token::Str("1071334a93244511adccb8d8b70eb1c2")],
        );*/

I'm working on a fix which will serialize compact to Token::Tuple which should be fine since the code is already broken

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