Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Releases: dtolnay/serde-yaml

0.9.4

03 Aug 00:10
0.9.4
d282c40
Compare
Choose a tag to compare
  • Add serde_yaml::with::singleton_map for serialization of enums as a 1-entry map (#300)
  • Reject duplicate keys when deserializing Mapping or Value (#301)

0.9.3

02 Aug 19:04
0.9.3
67ef14c
Compare
Choose a tag to compare
  • Add categories to crates.io metadata
  • Add keywords to crates.io metadata

0.9.2

30 Jul 05:50
0.9.2
3dd7bcf
Compare
Choose a tag to compare
  • Improve Debug representation of serde_yaml::Error

0.9.1

29 Jul 11:23
0.9.1
9eca262
Compare
Choose a tag to compare
  • Fix panic on some documents containing syntax error (#293)
  • Improve error messages that used to contain duplicative line/column information (#294)

0.9.0

28 Jul 21:36
0.9.0
4167a95
Compare
Choose a tag to compare

API documentation: https://docs.rs/serde_yaml/0.9

Highlights

  • The serde_yaml::Value enum gains a Tagged variant which represents the deserialization of YAML's !Tag syntax. Tagged scalars, sequences, and mappings are all supported.

  • An empty YAML input (or document containing only comments) will deserialize successfully to an empty map, empty sequence, or Serde struct as long as the struct has only optional fields. Previously this would error.

  • A new .apply_merge() method on Value implements YAML's << merge key convention.

  • The Debug representation of serde_yaml::Value has gotten vastly better (#287).

  • Deserialization of borrowed strings now works.

    #[derive(Deserialize, Debug)]
    struct Struct<'a> {
        borrowed: &'a str,
    }
    
    let yaml = "borrowed: 'kölcsönzött'\n";
    let value: Struct = serde_yaml::from_str(yaml)?;
    println!("{:#?}", value);
  • Value's and Mapping's methods get and get_mut have been generalized to support a &str argument, as opposed to requiring you to allocate and construct a Value::String for indexing into another existing Value.

  • Mapping exposes more APIs that have become conventional on map data structures, such as .keys(), .values(), .into_keys(), .into_values(), .values_mut(), and .retain(|k, v| …).

Breaking changes

  • Serialization no longer produces leading ---\n on the serialized output. You can prepend this yourself if your use case demands it.

  • Serialization of enum variants is now based on YAML's !Tag syntax, rather than JSON-style singleton maps.

    #[derive(Serialize, Deserialize)]
    enum Enum {
        Newtype(usize),
        Tuple(usize, usize, usize),
        Struct { x: f64, y: f64 },
    }
    - !Newtype 1
    - !Tuple [0, 0, 0]
    - !Struct {x: 1.0, y: 2.0}
  • A bunch of non-base-10 edge cases in number parsing have been resolved. For example 0x+1 and ++0x1 are now parsed as strings, whereas they used to be incorrectly treated as numbers.

  • Deserializers obtained through iteration can no longer be iterated further:

    let deserializer = serde_yaml::Deserializer::from_str(multiple_documents);
    for de in deserializer {
        // correct:
        let myvalue = T::deserialize(de)?;
    
        // incorrect: used to produce some questionable result, now produces 0 sub-documents
        for questionable in de {
            let wat = T::deserialize(questionable)?;
        }
    }
  • The abandoned yaml-rust crate is no longer used as the YAML backend. The new libyaml-based backend surely has different edge cases and quirks than yaml-rust.

  • Some excessive PartialEq impls have been eliminated.

  • The serde_yaml::to_vec function has been removed. Use serde_yaml::to_writer for doing I/O, or use serde_yaml::to_string + .into_bytes() on the resulting String.

  • The serde_yaml::seed module has been removed. Now that a serde_yaml::Deserializer is publicly available, the same use cases can be addressed via seed.deserialize(Deserializer::from_str(…)) instead.

Bugfixes

  • Empty values in a mapping are supported, and deserialize to empty string when the corresponding struct field is of type string. Previously they would deserialize to "~" which makes no sense.

  • 128-bit integer deserialization now supports hex and octal input.

  • Serde_yaml now includes a mitigation against a "billion laughs" attack in which malicious input involving YAML anchors and aliases is used to consume an amount of processing or memory that is exponential in the size of the input document. Serde_yaml will quickly produce an error in this situation instead.

0.8.26

16 Jul 05:33
0.8.26
c19c09d
Compare
Choose a tag to compare

0.8.25

08 Jul 19:04
0.8.25
c8bfe34
Compare
Choose a tag to compare
  • Add to "encoding" category on crates.io (#246)

0.8.24

03 May 19:14
0.8.24
915d013
Compare
Choose a tag to compare
  • Work around indexmap/autocfg not always properly detecting whether a std sysroot crate is available (#243, thanks @cuviper)

0.8.23

13 Dec 04:27
0.8.23
44ba879
Compare
Choose a tag to compare
  • Fix handling of YAML 1.1-style octals that begin with + or - sign (#228)

0.8.22

13 Dec 03:06
0.8.22
1db8fdb
Compare
Choose a tag to compare
  • Switch float serializer to use the same float formatting library as serde_json