Deser: Rethinking Rust Serialization 0 ▲ Armin Ronacher's Thoughts and Writings 1 hour ago · 15 min read2903 words · Tech · hide · 0 comments Serde is an amazing serialization library for Rust and it has been a huge reason why I felt productive with it for years. However already while at Sentry I got quite frustrated with some of the limitations with it but actually replacing Serde is tricky because of the might that it has in the ecosystem. Also because it’s quite hard to actually do better without also making some potentially painful compromises. Here are three examples of Serde corner cases that show poor interactions of Serde features or unexpected limitations: A number that is a map An internally tagged enum, with serde_json‘s arbitrary_precision feature turned on: #[derive(Deserialize)] #[serde(tag = "type")] enum Shape { Circle { radius: f64 }, } serde_json::from_str::<Shape>(r#"{"type": "Circle", "radius": 1.5}"#) // error: invalid type: map, expected f64 Serde’s data model has no place for arbitrary precision numbers, so serde_json uses in-band signalling with a map with a magic key. The enum has to buffer the… No comments yet. Log in to reply on the Fediverse. Comments will appear here.