cargo serde_derive 0.9.8

latest releases: 1.0.144, 1.0.143, 1.0.142...
7 years ago
  • Add with = "..." attribute that serves as a combination of serialize_with and deserialize_with (#763)

     #[derive(Serialize, Deserialize)]
     struct MyStruct {
    -    #[serde(serialize_with = "hyper_serde::serialize",
    -            deserialize_with = "hyper_serde::deserialize")]
    +    #[serde(with = "hyper_serde")]
         headers: Headers,
     }

    Whatever path you give, Serde will use $path::serialize as the serializer and $path::deserialize as the deserializer.

  • Haskell / Pandoc style adjacently tagged enums (#758, thanks @elliottslaughter)

    #[derive(Serialize, Deserialize)]
    #[serde(tag = "t", content = "c")]
    enum MyType {
        One(String),
        Two(u8, u8),
    }

    Written in JSON syntax, this enum would be represented as:

    { "t": "One", "c": "whatever string" }
    { "t": "Two", "c": [127, 1] }
  • Allow serde(default) attribute on structs (#780, thanks @Thomasdezeeuw)

    #[derive(Serialize, Deserialize)]
    #[serde(default)]
    struct StructDefault {
        a: i32,
        b: String,
    }
    
    impl Default for StructDefault {
        fn default() -> Self {
            StructDefault {
                a: 100,
                b: "default".to_string(),
            }
        }
    }
  • Clamp size hints coming from untrusted input to 4096 (#774, thanks @nox)

    This mitigates some types of attacks where untrusted input can instigate the allocation of large vectors or maps.

  • Optimize the serialization of various std::net types (#778, thanks @SimonSapin)

Don't miss a new serde_derive release

NewReleases is sending notifications on new releases.