Download Latest Version v0.42.0 - String Ergonomics source code.zip (1.6 MB) Google Add to Preferred Sources
Home / v0.42.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2026-08-22 8.2 kB
v0.42.0 - String Ergonomics source code.tar.gz 2026-08-22 1.5 MB
v0.42.0 - String Ergonomics source code.zip 2026-08-22 1.6 MB
Totals: 3 Items   3.2 MB 1

What's Changed

0.42.0 -- 2026-08-22

This is a large release. The primary change is an ergonomic improvement across the entire API - quick_xml now makes use of &str and String types where possible instead of &[u8] and Vec<u8>. This requires significant refactoring of downstream code, but should result in a net simplification as well as potential performance improvements, and opens up additional opportunities in future releases.

The MSRV has been raised to 1.86. We now use Rust 2024 Edition.

Breaking Changes

  • #963: Reader now validates that input is valid UTF-8 when constructing events. Non-UTF-8 input passed to Reader::from_reader() without DecodingReader will now produce Error::Encoding instead of silently passing through invalid bytes. Use DecodingReader to transcode non-UTF-8 sources.
  • #963: Name types (QName, LocalName, Prefix, Namespace, PrefixDeclaration) now wrap &str instead of &[u8]. into_inner() returns &str, and AsRef<str> is implemented (AsRef<[u8]> has been removed). ResolveResult::Unknown now contains String instead of Vec<u8>, and NamespaceError variants contain String instead of Vec<u8>.
  • #963: Removed the decoder: Decoder field from event types (BytesStart, BytesText, BytesCData, BytesRef) and Attributes. The decoder() method is no longer available on these types. Decode methods on events now always assume UTF-8 input. Error::missed_end() no longer takes a Decoder parameter.
  • #963: Event types (BytesStart, BytesEnd, BytesText, BytesCData, BytesPI, BytesRef) now store Cow<str> internally instead of Cow<[u8]>. into_inner() on BytesText, BytesCData, BytesPI, and BytesRef now returns Cow<str>. BytesStart::set_name() now takes &str instead of &[u8].
  • #963: All event types and the Event enum now implement Deref<Target = str> instead of Deref<Target = [u8]>. Explicit AsRef<str> impls are provided to avoid ambiguity.
  • #963: Removed decode() methods from BytesText, BytesCData, and BytesRef. Content is already available as &str via Deref. The xml10_content(), xml11_content(), xml_content(), and html_content() methods now return Cow<str> directly instead of Result<Cow<str>, EncodingError>.
  • #963: Attribute::value is now Cow<'a, str> instead of Cow<'a, [u8]>. The From<(&[u8], &[u8])> impl has been removed.
  • #963: BytesDecl::version(), encoding(), and standalone() now return Cow<'_, str> instead of Cow<'_, [u8]>.
  • #963: Removed Reader::decoder() method. Use Reader::encoding() instead (available with the encoding feature). Removed decoder() from the XmlRead serde trait. Removed all methods from Decoder (the struct is kept only for backward compatibility with deprecated Attribute methods).
  • #980: NamespaceError::TooManyDeclarations has been renamed to TooManyBindings, and NamespaceResolver::set_max_declarations_per_element has been renamed to NamespaceResolver::set_max_namespace_bindings, and the semantic behavior has changed slightly. The default maximum has also been reduced from 256 to 128.
  • #1000: DeError::UnexpectedStart renamed to DeError::MixedContent. That error is emitted when you try to deserialize boolean, number or string field from something like <field>text <tag/> another text</field>.

Bug Fixes

  • #670: Serde serializer now escapes \r, \n, and \t in attribute values as &#13;, &#10;, and &#9; respectively, preventing silent data loss from XML attribute-value normalization on round-trip. Likewise Attribute::from performs the same transformation.
  • #953: The serde Deserializer now correctly handles namespaces. Previously the namespace bindings might be applied or removed before the event actually was consumed which lead to a couple of bugs.
  • #989: Attributes::new and Attributes::html now return empty iterators when their starting position is past the end of the input instead of panicking.
  • #977: NamespaceResolver::push (and hence every NsReader Start/Empty event) now returns the new NamespaceError::TooDeeplyNested when a document nests elements deeper than u16::MAX, instead of overflowing the internal u16 depth counter. Previously the unguarded nesting_level += 1 panicked under overflow-checks builds and silently wrapped in release, corrupting namespace-scope bookkeeping on deeply nested untrusted input.
  • #980: NamespaceResolver now caps the total number of in-scope namespace bindings (default 128, configurable via set_max_namespace_bindings), replacing the previous per-element max_declarations_per_element limit.
  • #978: The serde Deserializer now enforces a configurable recursion-depth limit (default 128, matching serde_json). Deeply nested XML returns DeError::TooDeeplyNested instead of overflowing the native call stack. Use Deserializer::recursion_limit() to adjust.
  • #990: \r in text content is now escaped as &#13; by the serde serializer, BytesText::new(), escape(), partial_escape(), and minimal_escape(), preventing silent conversion to \n from XML end-of-line normalization on round-trip. Note that \r cannot be preserved through CDATA serialization because character references are not permitted inside CDATA sections.

Misc Changes

  • #269: Added getting-started examples (getting_started, writer, serde_roundtrip, reader_patterns, visitor) and an examples/README.md guide on choosing between the serde and pull-reader/writer APIs.
  • #331: Documentation about lifetimes of the events and attributes has been clarified.
  • #859: Added an example showing how to pretty-print serialized XML.
  • #983: Adopted an AI use and contribution policy for new upstream contributions.
  • #963: MSRV bumped to 1.86 (April 2025)
  • #963: Deprecated Attribute methods that take a Decoder parameter, since attribute values are now always valid UTF-8: decoded_and_normalized_value(), decoded_and_normalized_value_with(), decode_and_unescape_value(), and decode_and_unescape_value_with(). Use normalized_value() and normalized_value_with() instead.
  • #1002: Added NamespaceResolver::with that allows temporary applying namespace bindings from the start tag for the scope of a provided closure F, without making any persistent change to the resolver. It is useful to check a peeked event which is not yet consumed in custom implementations of peekable reader.
  • #1002: Added Deserializer::resolver and Deserializer::resolver_mut methods to get a namespace resolver used by this deserializer, because it no longer uses an NsReader internally.
  • #1005: Implement Hash, PartialOrd, and Ord for BytesText and BytesCData types.

New Contributors

Full Changelog: https://github.com/tafia/quick-xml/compare/v0.41.0...v0.42.0

Source: README.md, updated 2026-08-22