Closed howardjohn closed 1 year ago
I'm ok with this PR. But I'm not sure if the return value here is useful.
When error occurs, the returned Result
reports Error
, instead of transferred bytes. Personally I perfer to implement a custom Reader
or Writer
which meets those type constraints, to count transferred bytes in-time and do some custom sync operations on demand.
That's an interesting point. I was copying from https://docs.rs/tokio/latest/tokio/io/fn.copy_bidirectional.html but hadn't considered that. The Go version (https://pkg.go.dev/io#Copy) returns an error and bytes transferred because it is a tuple instead of a Result.
Reporting the bytes transferred while in progress would actually be most useful for us as well but may add some complexity
Merged, just to follow std & tokio. The overhead is quite small here.
Thanks!
This matches the behavior of std and Tokio copy methods, and allows doing things like reporting telemetry based on how much data is copied, for example.
The implementation follows
tokio
's bidi copy implementation.