This repository was archived by the owner on Aug 15, 2021. It is now read-only.
Implement de::from_slice_count#213
Open
ericmarkmartin wants to merge 5 commits intopyfisch:masterfrom
Open
Conversation
Add a function that deserializes first valid cbor value out of a slice of bytes and returns the number of consumed bytes.
Author
|
@Firstyear and I would really like this functionality for our work in kanidm/webauthn-rs, where we need to parse cbor values out of byte streams. |
Author
|
I'm also somewhat curious about why I have to subtract one off of the error's offset. |
dtolnay
reviewed
Mar 31, 2021
dtolnay
left a comment
There was a problem hiding this comment.
This use case doesn't strike me as warranting a dedicated API inside serde_cbor. I would prefer to recommend that the caller uses the following code instead, which I find simple/clear.
let mut deserializer = Deserializer::from_slice(slice);
let value = T::deserialize(&mut deserializer)?;
let processed = deserializer.byte_offset();|
Is there somewhere within the serde_cbor codebase where this could be added as an example usage? |
Author
Maybe in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a function that deserializes first valid cbor value out of a slice of bytes
and returns the number of consumed bytes.