Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async support #450

Merged
merged 6 commits into from Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion Cargo.toml
Expand Up @@ -8,13 +8,14 @@ documentation = "https://docs.rs/quick-xml"
repository = "https://github.com/tafia/quick-xml"

keywords = ["xml", "serde", "parser", "writer", "html"]
categories = ["encoding", "parsing", "parser-implementations"]
categories = ["asynchronous", "encoding", "parsing", "parser-implementations"]
license = "MIT"

[dependencies]
document-features = { version = "0.2", optional = true }
encoding_rs = { version = "0.8", optional = true }
serde = { version = "1.0", optional = true }
tokio = { version = "1.20", optional = true, default-features = false, features = ["io-util"] }
memchr = "2.5"

[dev-dependencies]
Expand All @@ -23,6 +24,8 @@ pretty_assertions = "1.2"
regex = "1"
serde = { version = "1.0", features = ["derive"] }
serde-value = "0.7"
tokio = { version = "1.20", default-features = false, features = ["macros", "rt"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't want to have support for from_file functions for the async reader, but I think we should still have at least one test which actually reads from a file, which would require the fs feature here. At least in dev-dependencies I think it's okay to have more features.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I do not see why we need to test actual reading from a file. I doubt that this test could catch something that is not catched by the test that read from memory. For example, we also does not have tests for sync reader that reads from a file (we have only two examples for that).

tokio-test = "0.4"

[lib]
bench = false
Expand All @@ -37,6 +40,13 @@ harness = false

[features]
default = []

## Enables support for asynchronous reading from `tokio`'s IO-Traits by enabling
## [reading events] from types implementing [`tokio::io::AsyncBufRead`].
##
## [reading events]: crate::reader::Reader::read_event_into_async
async-tokio = ["tokio"]

## Enables support of non-UTF-8 encoded documents. Encoding will be inferred from
## the XML declaration if it will be found, otherwise UTF-8 is assumed.
##
Expand Down Expand Up @@ -123,3 +133,7 @@ required-features = ["serialize"]
[[test]]
name = "serde-migrated"
required-features = ["serialize"]

[[test]]
name = "async-tokio"
required-features = ["async-tokio"]
2 changes: 2 additions & 0 deletions Changelog.md
Expand Up @@ -39,6 +39,7 @@
|`attribute_namespace` |`resolve_attribute`
- [#439]: Added utilities `detect_encoding()`, `decode()`, and `decode_with_bom_removal()`
under the `quick-xml::encoding` namespace.
- [#450]: Added support of asynchronous [tokio](https://tokio.rs/) readers


### Bug Fixes
Expand Down Expand Up @@ -218,6 +219,7 @@
[#439]: https://github.com/tafia/quick-xml/pull/439
[#440]: https://github.com/tafia/quick-xml/pull/440
[#443]: https://github.com/tafia/quick-xml/pull/443
[#450]: https://github.com/tafia/quick-xml/pull/450


## 0.23.0 -- 2022-05-08
Expand Down