Skip to content

Commit 53a7ad5

Browse files
999eagleMingun
authored andcommitted
Implement tokio-based asynchronous reader
1 parent 0ab5f4a commit 53a7ad5

File tree

8 files changed

+468
-22
lines changed

8 files changed

+468
-22
lines changed

Cargo.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ documentation = "https://docs.rs/quick-xml"
88
repository = "https://github.com/tafia/quick-xml"
99

1010
keywords = ["xml", "serde", "parser", "writer", "html"]
11-
categories = ["encoding", "parsing", "parser-implementations"]
11+
categories = ["asynchronous", "encoding", "parsing", "parser-implementations"]
1212
license = "MIT"
1313

1414
[dependencies]
1515
document-features = { version = "0.2", optional = true }
1616
encoding_rs = { version = "0.8", optional = true }
1717
serde = { version = "1.0", optional = true }
18+
tokio = { version = "1.20", optional = true, default-features = false, features = ["io-util"] }
1819
memchr = "2.5"
1920

2021
[dev-dependencies]
@@ -23,6 +24,8 @@ pretty_assertions = "1.2"
2324
regex = "1"
2425
serde = { version = "1.0", features = ["derive"] }
2526
serde-value = "0.7"
27+
tokio = { version = "1.20", default-features = false, features = ["macros", "rt"] }
28+
tokio-test = "0.4"
2629

2730
[lib]
2831
bench = false
@@ -37,6 +40,13 @@ harness = false
3740

3841
[features]
3942
default = []
43+
44+
## Enables support for asynchronous reading from `tokio`'s IO-Traits by enabling
45+
## [reading events] from types implementing [`tokio::io::AsyncBufRead`].
46+
##
47+
## [reading events]: crate::reader::Reader::read_event_into_async
48+
async-tokio = ["tokio"]
49+
4050
## Enables support of non-UTF-8 encoded documents. Encoding will be inferred from
4151
## the XML declaration if it will be found, otherwise UTF-8 is assumed.
4252
##
@@ -123,3 +133,7 @@ required-features = ["serialize"]
123133
[[test]]
124134
name = "serde-migrated"
125135
required-features = ["serialize"]
136+
137+
[[test]]
138+
name = "async-tokio"
139+
required-features = ["async-tokio"]

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
|`attribute_namespace` |`resolve_attribute`
4040
- [#439]: Added utilities `detect_encoding()`, `decode()`, and `decode_with_bom_removal()`
4141
under the `quick-xml::encoding` namespace.
42+
- [#450]: Added support of asynchronous [tokio](https://tokio.rs/) readers
4243

4344

4445
### Bug Fixes
@@ -218,6 +219,7 @@
218219
[#439]: https://github.com/tafia/quick-xml/pull/439
219220
[#440]: https://github.com/tafia/quick-xml/pull/440
220221
[#443]: https://github.com/tafia/quick-xml/pull/443
222+
[#450]: https://github.com/tafia/quick-xml/pull/450
221223

222224

223225
## 0.23.0 -- 2022-05-08

0 commit comments

Comments
 (0)