Skip to content

Commit

Permalink
Swap quick-xml references with fast-xml once again
Browse files Browse the repository at this point in the history
..after merging the fork back into the upstream.
  • Loading branch information
dralley authored and Mingun committed May 22, 2022
1 parent a181d0a commit 73e38f9
Show file tree
Hide file tree
Showing 26 changed files with 104 additions and 114 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "fast-xml"
name = "quick-xml"
version = "0.23.0"
description = "High performance xml reader and writer"
edition = "2018"

documentation = "https://docs.rs/fast-xml"
repository = "https://github.com/Mingun/fast-xml"
documentation = "https://docs.rs/quick-xml"
repository = "https://github.com/tafia/quick-xml"

keywords = ["xml", "serde", "parser", "writer", "html"]
categories = ["encoding", "parsing", "parser-implementations"]
Expand Down
38 changes: 14 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# fast-xml -- successor of [quick-xml]
# quick-xml

![status](https://github.com/Mingun/fast-xml/actions/workflows/rust.yml/badge.svg)
[![Crate](https://img.shields.io/crates/v/fast-xml.svg)](https://crates.io/crates/fast-xml)
![status](https://github.com/tafia/quick-xml/actions/workflows/rust.yml/badge.svg)
[![Crate](https://img.shields.io/crates/v/quick-xml.svg)](https://crates.io/crates/quick-xml)

High performance xml pull reader/writer.

Expand All @@ -10,27 +10,17 @@ The reader:
- is easy on memory allocation (the API provides a way to reuse buffers)
- support various encoding (with `encoding` feature), namespaces resolution, special characters.

[docs.rs](https://docs.rs/fast-xml)
[docs.rs](https://docs.rs/quick-xml)

Syntax is inspired by [xml-rs](https://github.com/netvl/xml-rs).

## Migration from [quick-xml]

If you using quick-xml 0.22.0 or 0.23.0-alpha3, you can just replace `quick-xml`
in your `Cargo.toml` with `fast-xml`. Replace each occurrence of `quick_xml`
crate name to `fast_xml` in your code base.

That two releases of fast-xml was specifically made for migration and contains
the same code as original quick-xml, except updated cargo metadata and extern
crate names in tests, benches and examples.

## Example

### Reader

```rust
use fast_xml::Reader;
use fast_xml::events::Event;
use quick_xml::Reader;
use quick_xml::events::Event;

let xml = r#"<tag1 att1 = "test">
<tag2><!--Test comment-->Test</tag2>
Expand Down Expand Up @@ -74,9 +64,9 @@ loop {
### Writer

```rust
use fast_xml::Writer;
use fast_xml::Reader;
use fast_xml::events::{Event, BytesEnd, BytesStart};
use quick_xml::Writer;
use quick_xml::Reader;
use quick_xml::events::{Event, BytesEnd, BytesStart};
use std::io::Cursor;
use std::iter;

Expand Down Expand Up @@ -120,17 +110,17 @@ assert_eq!(result, expected.as_bytes());

## Serde

When using the `serialize` feature, fast-xml can be used with serde's `Serialize`/`Deserialize` traits.
When using the `serialize` feature, quick-xml can be used with serde's `Serialize`/`Deserialize` traits.

Here is an example deserializing crates.io source:

```rust
// Cargo.toml
// [dependencies]
// serde = { version = "1.0", features = [ "derive" ] }
// fast-xml = { version = "0.22", features = [ "serialize" ] }
// quick-xml = { version = "0.22", features = [ "serialize" ] }
use serde::Deserialize;
use fast_xml::de::{from_str, DeError};
use quick_xml::de::{from_str, DeError};

#[derive(Debug, Deserialize, PartialEq)]
struct Link {
Expand Down Expand Up @@ -221,7 +211,7 @@ fn crates_io() -> Result<Html, DeError> {
### Credits

This has largely been inspired by [serde-xml-rs](https://github.com/RReverser/serde-xml-rs).
fast-xml follows its convention for deserialization, including the
quick-xml follows its convention for deserialization, including the
[`$value`](https://github.com/RReverser/serde-xml-rs#parsing-the-value-of-a-tag) special name.

Original [quick-xml] was developed by @tafia and abandoned around end of 2021.
Expand Down Expand Up @@ -282,7 +272,7 @@ Note that despite not focusing on performance (there are several unnecessary cop

Benchmarking is hard and the results depend on your input file and your machine.

Here on my particular file, fast-xml is around **50 times faster** than [xml-rs](https://crates.io/crates/xml-rs) crate.
Here on my particular file, quick-xml is around **50 times faster** than [xml-rs](https://crates.io/crates/xml-rs) crate.
_(measurements was done while this crate named quick-xml)_

```
Expand Down
4 changes: 2 additions & 2 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use criterion::{self, criterion_group, criterion_main, Criterion};
use fast_xml::events::Event;
use fast_xml::Reader;
use pretty_assertions::assert_eq;
use quick_xml::events::Event;
use quick_xml::Reader;

static SAMPLE: &[u8] = include_bytes!("../tests/sample_rss.xml");
static PLAYERS: &[u8] = include_bytes!("../tests/players.xml");
Expand Down
2 changes: 1 addition & 1 deletion compare/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dev-dependencies]
criterion = "0.3"
fast-xml = { path = "..", features = ["serialize"] }
quick-xml = { path = "..", features = ["serialize"] }
xml-rs = "0.8"
serde-xml-rs = "0.5"
serde = { version = "1.0", features = [ "derive" ] }
Expand Down
8 changes: 4 additions & 4 deletions compare/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{self, criterion_group, criterion_main, Criterion};
use pretty_assertions::assert_eq;
use fast_xml::{self, events::Event, Reader};
use quick_xml::{self, events::Event, Reader};
use serde::Deserialize;
use serde_xml_rs;
use xml::reader::{EventReader, XmlEvent};
Expand All @@ -11,7 +11,7 @@ static SOURCE: &str = include_str!("../../tests/sample_rss.xml");
fn low_level_comparison(c: &mut Criterion) {
let mut group = c.benchmark_group("low-level API");

group.bench_function("fast_xml", |b| {
group.bench_function("quick_xml", |b| {
b.iter(|| {
let mut r = Reader::from_reader(SOURCE.as_bytes());
r.check_end_names(false).check_comments(false);
Expand Down Expand Up @@ -77,9 +77,9 @@ fn serde_comparison(c: &mut Criterion) {
typ: String,
}

group.bench_function("fast_xml", |b| {
group.bench_function("quick_xml", |b| {
b.iter(|| {
let rss: Rss = fast_xml::de::from_str(SOURCE).unwrap();
let rss: Rss = quick_xml::de::from_str(SOURCE).unwrap();
assert_eq!(rss.channel.items.len(), 99);
})
});
Expand Down
4 changes: 2 additions & 2 deletions examples/custom_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//! * the regex in this example is simple but brittle;
//! * it does not support the use of entities in entity declaration.

use fast_xml::events::Event;
use fast_xml::Reader;
use quick_xml::events::Event;
use quick_xml::Reader;
use regex::bytes::Regex;
use std::collections::HashMap;

Expand Down
4 changes: 2 additions & 2 deletions examples/issue68.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unused)]

use fast_xml::events::Event;
use fast_xml::Reader;
use quick_xml::events::Event;
use quick_xml::Reader;
use std::io::Read;

struct Resource {
Expand Down
6 changes: 3 additions & 3 deletions examples/nested_readers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use fast_xml::events::Event;
use fast_xml::Reader;
use pretty_assertions::assert_eq;
use quick_xml::events::Event;
use quick_xml::Reader;

// a structure to capture the rows we've extracted
// from a ECMA-376 table in document.xml
Expand All @@ -12,7 +12,7 @@ struct TableStat {
// demonstrate how to nest readers
// This is useful for when you need to traverse
// a few levels of a document to extract things.
fn main() -> Result<(), fast_xml::Error> {
fn main() -> Result<(), quick_xml::Error> {
let mut buf = Vec::new();
// buffer for nested reader
let mut skip_buf = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions examples/read_texts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
use fast_xml::events::Event;
use fast_xml::Reader;
use quick_xml::events::Event;
use quick_xml::Reader;

let xml = "<tag1>text1</tag1><tag1>text2</tag1>\
<tag1>text3</tag1><tag1><tag2>text4</tag2></tag1>";
Expand Down
4 changes: 2 additions & 2 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

[package]
name = "fast-xml-fuzz"
name = "quick-xml-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
publish = false

[package.metadata]
cargo-fuzz = true

[dependencies.fast-xml]
[dependencies.quick-xml]
path = ".."
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/fuzz_target_1.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;

use fast_xml::Reader;
use fast_xml::events::Event;
use quick_xml::Reader;
use quick_xml::events::Event;
use std::io::Cursor;

fuzz_target!(|data: &[u8]| {
Expand Down
4 changes: 2 additions & 2 deletions src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
//! // Cargo.toml
//! // [dependencies]
//! // serde = { version = "1.0", features = [ "derive" ] }
//! // fast-xml = { version = "0.22", features = [ "serialize" ] }
//! // quick-xml = { version = "0.22", features = [ "serialize" ] }
//! # use pretty_assertions::assert_eq;
//! use serde::Deserialize;
//! use fast_xml::de::{from_str, DeError};
//! use quick_xml::de::{from_str, DeError};
//!
//! #[derive(Debug, Deserialize, PartialEq)]
//! struct Link {
Expand Down
4 changes: 2 additions & 2 deletions src/events/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<'a> From<(&'a [u8], &'a [u8])> for Attribute<'a> {
///
/// ```
/// # use pretty_assertions::assert_eq;
/// use fast_xml::events::attributes::Attribute;
/// use quick_xml::events::attributes::Attribute;
///
/// let features = Attribute::from(("features".as_bytes(), "Bells &amp; whistles".as_bytes()));
/// assert_eq!(features.value, "Bells &amp; whistles".as_bytes());
Expand All @@ -265,7 +265,7 @@ impl<'a> From<(&'a str, &'a str)> for Attribute<'a> {
///
/// ```
/// # use pretty_assertions::assert_eq;
/// use fast_xml::events::attributes::Attribute;
/// use quick_xml::events::attributes::Attribute;
///
/// let features = Attribute::from(("features", "Bells & whistles"));
/// assert_eq!(features.value, "Bells &amp; whistles".as_bytes());
Expand Down
16 changes: 8 additions & 8 deletions src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ impl<'a> BytesStart<'a> {
/// # Example
///
/// ```rust
/// # use fast_xml::{Error, Writer};
/// use fast_xml::events::{BytesStart, Event};
/// # use quick_xml::{Error, Writer};
/// use quick_xml::events::{BytesStart, Event};
///
/// struct SomeStruct<'a> {
/// attrs: BytesStart<'a>,
Expand Down Expand Up @@ -406,8 +406,8 @@ impl<'a> BytesDecl<'a> {
///
/// ```
/// use std::borrow::Cow;
/// use fast_xml::Error;
/// use fast_xml::events::{BytesDecl, BytesStart};
/// use quick_xml::Error;
/// use quick_xml::events::{BytesDecl, BytesStart};
///
/// // <?xml version='1.1'?>
/// let decl = BytesDecl::from_start(BytesStart::borrowed(b" version='1.1'", 0));
Expand Down Expand Up @@ -474,8 +474,8 @@ impl<'a> BytesDecl<'a> {
///
/// ```
/// use std::borrow::Cow;
/// use fast_xml::Error;
/// use fast_xml::events::{BytesDecl, BytesStart};
/// use quick_xml::Error;
/// use quick_xml::events::{BytesDecl, BytesStart};
///
/// // <?xml version='1.1'?>
/// let decl = BytesDecl::from_start(BytesStart::borrowed(b" version='1.1'", 0));
Expand Down Expand Up @@ -516,8 +516,8 @@ impl<'a> BytesDecl<'a> {
///
/// ```
/// use std::borrow::Cow;
/// use fast_xml::Error;
/// use fast_xml::events::{BytesDecl, BytesStart};
/// use quick_xml::Error;
/// use quick_xml::events::{BytesDecl, BytesStart};
///
/// // <?xml version='1.1'?>
/// let decl = BytesDecl::from_start(BytesStart::borrowed(b" version='1.1'", 0));
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! ## Description
//!
//! fast-xml contains two modes of operation:
//! quick-xml contains two modes of operation:
//!
//! A streaming API based on the [StAX] model. This is suited for larger XML documents which
//! cannot completely read into memory at once.
Expand All @@ -17,16 +17,16 @@
//! Especially for nested XML elements, the user must keep track _where_ (how deep) in the XML document
//! the current event is located. This is needed as the
//!
//! Furthermore, fast-xml also contains optional [Serde] support to directly serialize and deserialize from
//! Furthermore, quick-xml also contains optional [Serde] support to directly serialize and deserialize from
//! structs, without having to deal with the XML events.
//!
//! ## Examples
//!
//! ### Reader
//!
//! ```rust
//! use fast_xml::Reader;
//! use fast_xml::events::Event;
//! use quick_xml::Reader;
//! use quick_xml::events::Event;
//!
//! let xml = r#"<tag1 att1 = "test">
//! <tag2><!--Test comment-->Test</tag2>
Expand Down Expand Up @@ -74,9 +74,9 @@
//!
//! ```rust
//! # use pretty_assertions::assert_eq;
//! use fast_xml::Writer;
//! use fast_xml::events::{Event, BytesEnd, BytesStart};
//! use fast_xml::Reader;
//! use quick_xml::Writer;
//! use quick_xml::events::{Event, BytesEnd, BytesStart};
//! use quick_xml::Reader;
//! use std::io::Cursor;
//! use std::iter;
//!
Expand Down Expand Up @@ -121,7 +121,7 @@
//!
//! # Features
//!
//! fast-xml supports 2 additional features, non activated by default:
//! quick-xml supports 2 additional features, non activated by default:
//! - `encoding`: support non utf8 XMLs
//! - `serialize`: support serde `Serialize`/`Deserialize`
//!
Expand Down
Loading

0 comments on commit 73e38f9

Please sign in to comment.