Skip to content

Remove the ability to use SliceReader with raw bytes #436

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

Closed
wants to merge 12 commits into from

Conversation

dralley
Copy link
Collaborator

@dralley dralley commented Jul 23, 2022

In the near future, decoding will be performed automatically as the input is read. If the input has an unknown encoding, it must be decoded first, necessitating a buffer. Therefore only the buffered implementation can be used for Reader::from_bytes()

If the encoding of the bytes is known up-front, you can decode them up-front and subsequently use Reader::from_str() for borrowing behavior if desired.

Made some utilities such as detect_encoding(), decode(), and decode_with_bom_removal() available as standalone functions so that they can be used on user-provided data.

Mingun and others added 9 commits July 20, 2022 12:00
This commit only moves code without significant changes (the only changes is:
- corrected imports
- add imports to the doc comments which have become inaccessible
)
Main code moved from `read_namespaced_event_into` to `resolve_namespaced_event_inner`
This also changes the test cases in the `reader::test::check` macro to allow for reader-specific tests.
@dralley dralley requested a review from Mingun July 23, 2022 03:13
@dralley dralley marked this pull request as draft July 23, 2022 03:24
@dralley dralley marked this pull request as ready for review July 23, 2022 03:43
@dralley
Copy link
Collaborator Author

dralley commented Jul 23, 2022

Waiting on #425

Next: Decoding into an internal buffer, then parsing the decoded data

After: Evaluate whether user-provided buffers are still useful once we already have one internally anyway - if the benefit is minimal or nonexistent the API can be collapsed back into borrowing-based APIs which would allow us to deduplicate a bunch of code again.

After: Swap the internals of Event, Attribute, etc. and remove the decoding functionality and wrappers

Reader::from_reader_internal(BufferedReader(bytes))
}

#[cfg(feature = "encoding")]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moving these because it doesn't make sense to check these for both when SliceReader can't work with encoded bytes.

@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2022

Codecov Report

Merging #436 (cc17a44) into master (ebbcce0) will increase coverage by 2.53%.
The diff coverage is 79.22%.

@@            Coverage Diff             @@
##           master     #436      +/-   ##
==========================================
+ Coverage   49.51%   52.04%   +2.53%     
==========================================
  Files          22       26       +4     
  Lines       13847    13453     -394     
==========================================
+ Hits         6856     7002     +146     
+ Misses       6991     6451     -540     
Flag Coverage Δ
unittests 52.04% <79.22%> (+2.53%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
benches/macrobenches.rs 0.00% <0.00%> (ø)
benches/microbenches.rs 0.00% <0.00%> (ø)
examples/read_buffered.rs 0.00% <0.00%> (ø)
examples/read_texts.rs 0.00% <0.00%> (ø)
src/de/escape.rs 21.05% <ø> (ø)
src/de/seq.rs 91.83% <ø> (ø)
src/de/simple_type.rs 90.63% <ø> (ø)
src/events/mod.rs 68.20% <ø> (ø)
src/lib.rs 12.26% <0.00%> (ø)
src/reader/buffered_reader.rs 76.87% <76.87%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebbcce0...cc17a44. Read the comment docs.

@dralley dralley marked this pull request as draft July 23, 2022 04:41
dralley added 2 commits July 23, 2022 10:28
In the near future, decoding will be performed automatically as the
input is read. If the input has an unknown encoding, it must be decoded
first, necessitating a buffer. Therefore only the buffered
implementation can be used for `Reader::from_bytes()`

If the encoding of the bytes is known up-front, you can decode them
up-front and subsequently use `Reader::from_str()` if desired.
@dralley dralley added the encoding Issues related to support of various encodings of the XML documents label Jul 23, 2022
@dralley dralley closed this Jul 24, 2022
@dralley dralley deleted the buffer-decode2 branch July 24, 2022 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
encoding Issues related to support of various encodings of the XML documents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants