Skip to content

Releases: serde-rs/serde

v0.9.12

27 Mar 23:15
v0.9.12
59b3961
Compare
Choose a tag to compare
  • Add #[serde(into = "T")] to serialize using the implementation of Into<T> and #[serde(from = "T")] to deserialize using the implementation of From<T> (#817, thanks @jbaublitz)

    #[derive(Serialize, Deserialize)]
    #[serde(into = "u32", from = "u32")]
    struct Ipv4Addr {
        /* ... */
    }
  • Implement Deserialize for Box<CStr> on nightly (#811, thanks @jonhoo)

  • Implement Serialize and Deserialize for OsString and implement Serialize for OsStr (#824, thanks @alexcrichton)

  • Implement Serialize for Range (#813, thanks @rocallahan)

v0.9.11

06 Mar 00:59
v0.9.11
dc9445f
Compare
Choose a tag to compare

v0.9.10

28 Feb 20:49
v0.9.10
51ed9c2
Compare
Choose a tag to compare
  • Add a rename_all attribute to rename all the fields of a struct or struct variant, or all the variants of an enum.

    #[derive(Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    struct S {
        first_field: u8, // gets renamed to firstField
        second_field: u8, // gets renamed to secondField
    }

    The possible renames are:

    • #[serde(rename_all = "PascalCase")]
    • #[serde(rename_all = "camelCase")]
    • #[serde(rename_all = "snake_case")]
    • #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
    • #[serde(rename_all = "kebab-case")]

v0.9.9

24 Feb 22:02
v0.9.9
59ec931
Compare
Choose a tag to compare
  • Fix a bug causing externally tagged enums inside of untagged / internally tagged enums to fail to deserialize (#775 and serde-rs/json#248)

v0.9.8

21 Feb 19:13
v0.9.8
017e6d3
Compare
Choose a tag to compare
  • 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)

v0.9.7

10 Feb 02:23
v0.9.7
964a2dd
Compare
Choose a tag to compare
  • Add Serializer::collect_seq and Serializer::collect_map to simplify some Serialize impls (#736)

    - let mut map = serializer.serialize_map(Some(self.len()))?;
    - for (k, v) in self {
    -     map.serialize_key(k)?;
    -     map.serialize_value(v)?;
    - }
    - map.end()
    + serializer.collect_map(self)

v0.9.6

03 Feb 20:32
v0.9.6
d1306a7
Compare
Choose a tag to compare
  • Support for untagged and internally tagged enum representations; see the manual for details (#739)
  • Remove Serialize and Deserialize impls for collections::enum_set::EnumSet which has been deprecated for a long time (#740)
  • Fix compilation errors in generated code when Ok or Err were redefined from their usual meaning within the same module (#737)

v0.9.5

01 Feb 09:03
v0.9.5
d960571
Compare
Choose a tag to compare
  • Remove clippy dependency to unblock the documentation build in docs.rs

v0.9.4

31 Jan 02:23
v0.9.4
297f373
Compare
Choose a tag to compare
  • Provide serde::ser::Impossible, a helper for Serializer implementations that do not support serializing one of the compound types (#694)

v0.9.3

28 Jan 23:16
v0.9.3
8624ca6
Compare
Choose a tag to compare
  • Fix invalid-length error message for arrays and tuple that incorrectly claimed the length was always 0