1
use serde::{Deserialize, Serialize};
2

            
3
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
4
#[serde(tag = "type")]
5
enum Message {
6
    Request {
7
        id: u32,
8
        resource: String,
9
        operation: String,
10
    },
11
    Response {
12
        id: u32,
13
        value: String,
14
    },
15
}
16

            
17
#[test]
18
4
fn internally_tagged_enum_serde_core_content_detection() {
19
4
    let value = Message::Response {
20
4
        id: 60069,
21
4
        value: "Foobar".into(),
22
4
    };
23
4
    let serialized = ron::to_string(&value).unwrap();
24
4
    let deserialized: Message = ron::from_str(&serialized).unwrap();
25
4
    assert_eq!(deserialized, value);
26
4
}