-
Notifications
You must be signed in to change notification settings - Fork 41
Consider Removing the io::Read
and io::Write
supertraits on AsyncRead and AsyncWrite
#83
Comments
One of the biggest motivational factors for the current design was for integration with the In that sense it seems like this would theoretically solve that constraint but I'd recommend getting the legwork done to prove this out if we're seriously considering this. I'm personally pretty wary of the impact this would have on downstream crates for what I'd see as not a whole lot of benefit, although I could be wrong! |
Can you explain more what you're looking for here? I'd be happy to put in some time on this, but I don't see why any changes would be needed to |
Oh sorry sure yeah. What I mean is that |
As a counter point, I am pretty sure that
If trait AsyncRead {
fn into_std(self) -> Std(Self);
fn as_std(&mut self) -> Std(&mut self);
}
impl<T: AsyncRead> io::Read for Std(T) {
// ...
} |
The tokio-io crate has been moved into the tokio git repo. I created a new issue over there. See link above. |
Many of the methods on
io::Read
andio::Write
, such aswrite_all
, are not appropriate to call in an async context. Furthermore, lots of code usingio::Read
andio::Write
expects (correctly or not) that those interfaces are blocking. Removing the supertraits would make it harder to misuse theAsyncRead
andAsyncWrite
types asio::Read
andio::Write
types, and would allow moving theio::XXX
functions to methods on theAsyncRead
andAsyncWrite
traits (this last point is a benefit because methods are more easily discoverable than free functions). This change could also allowAsyncRead
andAsyncWrite
types with non-io::Error
error types.There are places in which it makes sense to provide an async-readable/writeable type as an
io::Read
orio::Write
. That functionality can still be provided by choosing to opt-in to anio::Read
orio::Write
impl, or by using some form of wrapper type which allows using anAsyncRead
/AsyncWrite
as anio::Read
/io::Write
(basically the inverse of #76).cc @carllerche
The text was updated successfully, but these errors were encountered: