Skip to content

Upgrading quick-xml 0.41 to 0.42

Breaking0.41.0 → 0.42.0Breaking11Platform1Deprecated1New3Fixed7Other4

BreakingUpgrade verdict

11 breaking changes and a platform requirement change.

  • Events no longer carry a decoder, and decoding always assumes UTF-8 text.
  • You no longer call decode() on text events because content is already text.
  • Attribute values are now text strings rather than byte slices.
  • Use Reader::encoding() instead of Reader::decoder() to inspect the encoding.
Top 5 of 13 that need code or config changes

Rust requirement changed in 0.42.0: 1.79 → 1.86.

Breaking11
Removes the decoder field and decoder() method from event types and Attributes; decode methods now assume UTF-8.
BytesStartBytesTextBytesCDataBytesRefAttributesdecoder()Error::missed_end()
Removes decode() from BytesText, BytesCData and BytesRef; content methods now return Cow<str> directly.
BytesTextBytesCDataBytesRefdecode()xml10_content()xml11_content()xml_content()html_content()
Attribute::value is now Cow<str> and the From<(&[u8], &[u8])> impl is removed.
Attribute::valueFrom<(&[u8], &[u8])>
Removes Reader::decoder() and the XmlRead serde decoder() method, and removes all methods from Decoder.
Reader::decoder()Reader::encoding()XmlReadDecoder
Renames NamespaceError::TooManyDeclarations to TooManyBindings and set_max_declarations_per_element to set_max_namespace_bindings, lowering the default to 128.
NamespaceError::TooManyDeclarationsNamespaceError::TooManyBindingsNamespaceResolver::set_max_declarations_per_elementNamespaceResolver::set_max_namespace_bindings
Renames DeError::UnexpectedStart to DeError::MixedContent for mixed-content deserialization errors.
DeError::UnexpectedStartDeError::MixedContent
Reader now validates that input is valid UTF-8 when constructing events, producing Error::Encoding for non-UTF-8 input.
ReaderReader::from_reader()DecodingReaderError::Encoding
Name types now wrap &str instead of &[u8], and related error and resolve types use String instead of Vec<u8>.
QNameLocalNamePrefixNamespacePrefixDeclarationinto_inner()ResolveResult::UnknownNamespaceError
Event types now store Cow<str> internally, and into_inner() and set_name() use str types.
BytesStartBytesEndBytesTextBytesCDataBytesPIBytesRefinto_inner()BytesStart::set_name()
Event types and the Event enum now implement Deref<Target = str> instead of Deref<Target = [u8]>.
EventDerefAsRef<str>
BytesDecl::version(), encoding() and standalone() now return Cow<str> instead of Cow<[u8]>.
BytesDecl::version()BytesDecl::encoding()BytesDecl::standalone()
Platform1
Bumps the minimum supported Rust version (MSRV) to 1.86 (April 2025).
Deprecated1
Deprecates Attribute methods taking a Decoder, since attribute values are always valid UTF-8.
Attributedecoded_and_normalized_value()decoded_and_normalized_value_with()decode_and_unescape_value()decode_and_unescape_value_with()normalized_value()normalized_value_with()