How can I support an unknown or other value for a Serde enum?
问题 I have a JSON API that returns an object that looks like this: { "PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp" } To capture this, I have an enum and a struct: #[derive(Eq, PartialEq, Deserialize, Serialize, Debug)] #[serde(rename_all = "snake_case")] pub enum PortType { Sctp, Tcp, Udp, } #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "PascalCase")] pub struct PortMapping { pub private_port: u16, pub public_port: u16, #[serde(rename = "Type")] pub port_type: PortType, }