Skip to content

Comments

Make BytesCData decode method public#857

Merged
Mingun merged 1 commit intotafia:masterfrom
mematthias:master
Apr 26, 2025
Merged

Make BytesCData decode method public#857
Mingun merged 1 commit intotafia:masterfrom
mematthias:master

Conversation

@mematthias
Copy link
Contributor

Currently, retrieving the decoded string content of a quick_xml::events::Event::CData(cdata) requires manually obtaining the Decoder instance from the Reader and calling reader.decoder().decode(cdata.as_ref())

This PR addresses this by changing the visibility of the internal decode method associated with BytesCData from pub(crate) to pub.

This enables users to directly call the decoding logic on the BytesCData instance itself:

match cdata.decode() {
    Ok(decoded_string) => { /* ... */ }
    Err(err) => { /* ... */ }
}

Copy link
Collaborator

@Mingun Mingun left a comment

Choose a reason for hiding this comment

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

Could you also add a changelog entry similarly to existing entries?

Comment on lines 846 to 852
/// Gets content of this text buffer in the specified encoding
pub(crate) fn decode(&self) -> Result<Cow<'a, str>, EncodingError> {
pub fn decode(&self) -> Result<Cow<'a, str>, EncodingError> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to change doc string, because it is currently outdated. Will be used an encoding of a reader from which this event was produced.

@mematthias mematthias requested a review from Mingun April 26, 2025 16:00
@codecov-commenter
Copy link

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

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.74%. Comparing base (a9391f3) to head (4acc194).
Report is 39 commits behind head on master.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #857      +/-   ##
==========================================
+ Coverage   60.21%   60.74%   +0.53%     
==========================================
  Files          41       41              
  Lines       16021    16047      +26     
==========================================
+ Hits         9647     9748     +101     
+ Misses       6374     6299      -75     
Flag Coverage Δ
unittests 60.74% <100.00%> (+0.53%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Mingun Mingun merged commit a7cb878 into tafia:master Apr 26, 2025
7 checks passed
@Mingun
Copy link
Collaborator

Mingun commented Apr 26, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants