Skip to content

Add deserialize_exact APIs to reject trailing bytes#254

Open
tanmay4l wants to merge 2 commits intoanza-xyz:masterfrom
tanmay4l:config
Open

Add deserialize_exact APIs to reject trailing bytes#254
tanmay4l wants to merge 2 commits intoanza-xyz:masterfrom
tanmay4l:config

Conversation

@tanmay4l
Copy link
Copy Markdown
Contributor

@tanmay4l tanmay4l commented Mar 21, 2026

Fixes #199

@tanmay4l tanmay4l marked this pull request as ready for review March 23, 2026 20:15
Copy link
Copy Markdown
Contributor

@kskalski kskalski left a comment

Choose a reason for hiding this comment

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

I think this is the correct API we want to have.

Additional thoughts on those modules - I'm looking into cleaning up the serde functions, so far the idea is to:

  • remove traits and rely only on free functions (this addition meets the criteria of target API to stay) or let user use Schema* directly (any more complex use-case not permitted by free function)
  • switch input slices to impl Reader - current deserialize_exact goes against this direction - alternative would be to enrich Reader with has_data API, which might be a way to go, it could be inefficient for non-slice readers, but given that checking for trailing bytes will only be done on demand with the top level functions, maybe it's fine @cpubot ?
  • remove deserialize_from (superceded by deserialize taking Reader)

Copy link
Copy Markdown
Contributor

@cpubot cpubot left a comment

Choose a reason for hiding this comment

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

I think this API shape is fine as is. We need not consider further API reorganization to ship this functionality. Once we have an agreed upon direction as far as an API re-design / reorganization, we can figure out how to handle in that context.

Another note: we should add clear documentation to these functions as well with doctests.

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.

Support reject_trailing_bytes config option

3 participants