-
Notifications
You must be signed in to change notification settings - Fork 508
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
feat(core): Implement write and write_from for Writer #4482
Conversation
Got this, thank you for your guidance, I will modify the api implementation and related uses in the codes later. |
This in itself is not very important, because it does not affect the implementation and API, but I have a little confuse about the use of Buffer and bytes::Bytes in the code. For example, Bytes is used to generate input in the bench and fuzz tests now. Is it necessary to reduce the direct usage of Bytes and replace it entirely with Buffer? Or we just focus on the API interface and the implementation underneath the API. The usage elsewhere in the code doesn't matter. |
I feel like we don't need to.
Yes, the point of Buffer is public API. |
core/src/layers/complete.rs
Outdated
@@ -806,7 +806,7 @@ mod tests { | |||
#[tokio::test] | |||
async fn test_writer() { | |||
let op = new_test_operator(Capability::default()); | |||
let res = op.write("path", vec![]).await; | |||
let res = op.write("path", Vec::<u8>::new()).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change required? I expect vec![]
can work as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be necessary because we have implemented conversion from Vec<u8>
and Vec<Bytes>
for Buffer
. If we directly vec![]
, the compiler cannot determine which one it is and will report an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing the code here into following for better reading?
let bs: Vec<u8> = vec![];
let res = op.write("path", bs).await;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
related to: #4465