-
Notifications
You must be signed in to change notification settings - Fork 36
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
Should StreamingDecoder::read_exact
prefer Read::read_exact
's contract over its own?
#69
Comments
I think The motivation given in #57 (comment) is that a TCP stream is potentially endless, but It is quite unergonomic to need to do https://github.com/gimli-rs/object/pull/730/files for what to me is a normal use case. |
I had a look at implementing a version of I think what I really want is the equivalent of |
The FrameDecoder has an interface similar to these functions. It might also be better to just hide the whole complexity behind a convenience function like If this documents the risks behind using this function, maybe offering a variant that doesn't return a vec but writes to a slice (or a generic Write) I'd be fine with that. |
Should be dealt with by #70 ? Please reopen if there is anything still missing |
You of course have already seen rust-lang/backtrace-rs#626 and I figured I'd capture some thoughts about the discussion there.
I won't try to persuade you that
StreamingDecoder::read
should behave differently in the general case! But it would seem more natural, to me, for theRead::read_exact
case to have more of a "do what I mean" quality to it, even though this contradicts the documentation ofStreamingDecoder
that says:Personally, I tend to dislike
read_exact
for the precise reason that it seems like a much more "magical" function to me thanread
, as it says "Reads the exact number of bytes required to fillbuf
. This function reads as many bytes as necessary to completely fill the specified bufferbuf
." and is very prone to leaving the buffer and reader in unspecified states, considering:Naturally of course there could be another Decoder type that implements such semantics, but would it really differ, if you had your way, on more than this one function?
The text was updated successfully, but these errors were encountered: