-
Notifications
You must be signed in to change notification settings - Fork 304
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
BytesMut does not implement io::Write #425
Comments
It's implemented, but only through bytes::buf::BufMutExt trait (method writer). |
Thank you, had not noticed, I can remove my own wrapper now ^^' |
It does seem like it could be implemented... I can't remember, I feel it used to be. Did we remove it? |
Came across this today and just wanted to update for future readers that in 0.6.0, |
Can we bring back the writer in BufMutExt? Consider the use case where one is using both BufMut methods, and wants to also use Write methods. If the use case involves using both BufMut methods and Write methods on a given instance, BufMutExt would be a good fit. |
It still looks like it could be implemented directly on |
yea, directly on BytesMut, could look something like:
The docs do say that Buf and BufMut "serve different purposes" from Read and Write. However, while working with actix-web, the HTTP Response object takes body composed of Bytes. To efficiently construct Bytes, I use a BytesMut, where portions of the protocol framing are best handled by buf.put_*(), while other parts are handled by serde::to_writer(), which wants a Write object. It'd be nice to have a direct implementation somewhat similar to how Vec implements Write, if that's reasonable of course. |
I'd be glad to write a PR if needed. Are there design concerns about this? For example, should Write be implemented on a separate BytesMutExt trait to keep it separate, or should it be directly on BytesMut? The reason as ask is... writer() eventually moved from the extension to directly on BytesMut. If that's where Write would eventually end up, it may be helpful if it's there from the start. Here's why. Look at the current stable actix-web 3.3.2 for example. It uses bytes version 0.5.3 released December 12, 2019. Sol there's the possibility that changes such as this may delayed for dependent crates, and the impact of changing ti from BytesMutExt to BytesMut could occur long afterward. |
I submitted a PR #478 to implement Write for BytesMut. |
Is there any particular reason why
BytesMut
does not implementstd::io::Write
?Vec<u8>
has it implemented. It looks likeBytesMut
should support that as well.(NB:
BytesMut
hasstd::fmt::Write
implemented, I'm talking aboutio::Write
here, which is a different trait)The text was updated successfully, but these errors were encountered: