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

Implement ability to read data directly from the underlying reader #783

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

Mingun
Copy link
Collaborator

@Mingun Mingun commented Jul 12, 2024

Closes #623

This also implements #260, but the user should manually:

  • ensure, that it is reading text
  • stop reading when text ends

So I do not consider that #260 is solved.

@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 87.75510% with 6 lines in your changes missing coverage. Please review.

Project coverage is 60.09%. Comparing base (7558577) to head (b112663).
Report is 91 commits behind head on master.

Files Patch % Lines
src/reader/mod.rs 77.77% 6 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #783      +/-   ##
==========================================
- Coverage   61.81%   60.09%   -1.72%     
==========================================
  Files          41       41              
  Lines       16798    16097     -701     
==========================================
- Hits        10384     9674     -710     
- Misses       6414     6423       +9     
Flag Coverage Δ
unittests 60.09% <87.75%> (-1.72%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

/// # Example
///
/// This example demonstrates, how it is possible to read embedded binary data.
/// Such XML documents are exist in the wild.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This example demonstrates how to read stream raw bytes from an XML document. This could be used to implement streaming read of text, or to read raw binary bytes embedded in an XML document. (Documents with embedded raw bytes are not valid XML, but XML-derived file formats exist where such documents are valid).

/// // Reading from the stream() advances position
/// let mut inner = reader.stream();
///
/// // Read binary data. We somehow should known its size
Copy link
Collaborator

Choose a reason for hiding this comment

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

We must know its size

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also somewhere (maybe up above, not here), we should mention the two conditions that the user must uphold when using this API and the potential consequences if it's misused.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mmm... what two conditions? I added a note that read data will not be returned in subsequent Events

Copy link
Collaborator

Choose a reason for hiding this comment

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

the user should manually:

  • ensure, that it is reading text (binary data)
  • stop reading when text (binary data) ends

Copy link
Collaborator

Choose a reason for hiding this comment

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

Basically there are many possible uses of stream(), but for basically all uses it can be presumed that you probably don't intend to end in the middle of an event or an attribute or something

Copy link
Collaborator Author

@Mingun Mingun Jul 15, 2024

Choose a reason for hiding this comment

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

ensure, that it is reading text (binary data)

Technically speaking, everything which would be read thru this method is a binary data (in particular, it may look as a valid and well-formed XML markup). So that this is not very helpful recommendation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dralley, what do you think about my last comment? If you think, that we can write something clear do not hesitate to write it -- I decidedly have no thoughts. I mean, that just "when binary data ends" is not clear enough, because this literally can be any condition which is already clear.

Co-authored-by: Daniel Alley <dalley@redhat.com>
@Mingun Mingun merged commit 21360fe into tafia:master Jul 22, 2024
7 checks passed
@Mingun Mingun deleted the binary-stream branch July 22, 2024 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for embedded raw binary
3 participants