Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Problem deserializing tagged enum (serde) #548

@jbrosi

Description

@jbrosi

Hey there, I have the following code:

use serde::{Deserialize, Serialize};

fn main() {
     #[derive(Debug, Serialize, Deserialize)]
    struct Struct {
        a: u8,
    }
    #[derive(Debug, Serialize, Deserialize)]
    #[serde(tag = "version")]
    enum Test {
        Variant(Struct),
    }

    let data = Test::Variant(Struct { a: 7 });
    let serialized = bincode2::serialize(&data).unwrap();
    let deserialized: Test = bincode2::deserialize(&serialized).unwrap();

}

The deserialize fails with DeserializeAnyNotSupportedwhen I have the #[serde(tag="version")] enabled like above. If i remove it, it does work. Serialize always works and seems to put additional info when tagging is enabled. Couldn't find any hints on how to solve this and this does not seem to be known issue (https://docs.rs/bincode/2.0.0-alpha.1/bincode/serde/index.html#known-issues).

The behavior is the same for bincode 2.0.1 and 1.3.3.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions