-
Notifications
You must be signed in to change notification settings - Fork 364
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
Define a separate trait for reading objects that know when to stop vs not #3292
Comments
Could you be more specific about the cases where this leads to unsafe situations? |
probably when you mix the two types, but I could be wrong |
I don't see how that would be any more unsafe than reading smth. from a stream in general. It's either long enough, or it isn't. If you try to read something after reading an object that reads to the end, the stream has no data left. I may be missing something here. Maybe Matt had a more specific example in mind? |
Its not "unsafe" in the Rust "can lead to language-undefined behavior" definition, but rather unsafe in the "can lead to bugs" sense. If you have an object which is being read and it tries to read some sub-object which unexpectedly consumes the whole stream things may spuriously fail to deserialize or read the wrong fields. |
We currently have one trait (
Readable
) for reading objects with two totally different semantics - objects may know when to stop reading cause they have length descriptors and some objects may not (cause they just read to end). We should really have two different traits for the two types of objects cause its unsafe to confuse them.The text was updated successfully, but these errors were encountered: