-
Notifications
You must be signed in to change notification settings - Fork 137
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
serdect: slice::deserialize_hex_or_bin
needs to return the amount of deserialized data
#1322
Comments
Ah, my bad, didn't realize from the docstring it was a part of the contract, and I don't think there was a test for it either. But the functionality does sound necessary now that I think about it. |
Making a PR to fix this now, but I wonder: if it's the length of the deserialized data we're interested in, should we just return that and not the buffer reference? |
IMO it's more idiomatic in Rust to return the slice whenever possible. You can always get the length if that's all you're interested in by calling |
I understand that the slice provides the information we want, I was wondering whether we should return extra information (the actual contents of the slice), or try to limit the return value to just the information we want. But I have no strong feelings about it, I'll go with the slice. |
There are many existing usages of the |
This is tracking a regression from #1112, where
slice::deserialize_hex_or_bin
was changed to returnResult<(), D::Error>
instead ofResult<&[u8], D::Error>
.Notably this API is intended for use cases where the amount of deserialized data can vary, and may be shorter than the provided
buffer
parameter. The ability to handle messages shorter thanbuffer
has been lost.See #1112 (comment)
The text was updated successfully, but these errors were encountered: