-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Move Read
and Write
traits into libcore
#1314
Comments
|
This would be great, but unfortunately, |
Ugh, I overlooked that completely! |
I guess that changes the shape of this issue a bit. What kind of proto-Read and proto-Write can core provide? Ideally it should seamlessly scale up to full Read / Write with libstd. The error could be an associated type in the core traits. |
An associated error type was discussed as part of the Great IO Overhaul, but ended up being incredibly painful to actually work with IIRC. I can't remember if that discussion was on the original rfc or one of the followups though. |
This was actually originally proposed in the I/O reform as it turns out 90% of the adapters and helper methods and such can all live in libcore rather than requiring the standard library. For this to work, however, there were two key assumptions:
I made attempts to have an associated error type, and it ended up being very painful to write any amount of generic code over I/O adapters and such. Lots more discussion can be found on the I/O RFCs :) As a result I don't think we can do this, although there may be perhaps some kernel or subset that could be extracted in the future. |
Check out https://github.com/RustOS-Fork-Holding-Ground/coreio! Pull requests adding the various composite readers/writers would be appreciated (@Tobba and I have written things on an as-needed basis). |
I am going to close this. A future issue needs a more concrete plan for how to make it work. Thanks! |
I should also note that some of composers (e.g. Now that the |
rust-lang/rust#48331 Linking this open issue here, because this thread comes up at Google results while trying to search for the current, open issue. |
The traits
Read
andWrite
are simple and fundamental (they require and typically use 1 and 2 methods respectively).It would be nice for the whole ecosystem to provide these in libcore.
Read
andWrite
are at their core simple and non-allocating, both traits should be core compatible.However,
Read
has some extension methods that depend on collections --fn read_to_end(&mut self, &mut Vec<u8>
. This is the main obstacle to any simple move from std to core.I don't have a plan at hand how to achieve this; a core
Read
and an extension trait in libstd could achieve exactly the same interface, but with the unfortunate fact that it would be a breaking change for some code, for example those implementingRead::read_to_end
explicitly.The text was updated successfully, but these errors were encountered: