No obvious way to set a read limit for read_until #3346
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
M-io
Module: tokio/io
In standard library, it's possible to call BufRead's
read_until
with a read limit using a pattern like this:The
by_ref()
call allows us to reuse the reader later. The same pattern works inasync_std
, as itsReadExt
trait implementsby_ref
:Tokio only implements
by_ref
for*Half
traits, which means the above one-liner doesn't work after wrappeng them in aBufReader
. I don't see any other way of imposing a read limit onread_until
in Tokio other than reimplementing it.I suppose the simplest (end-user wise) way to fix this would be to implement
by_ref
inAsyncReadExt
for anyAsyncRead
. I have no idea how hard it is, #2716 mentions some trouble implementingby_ref
forTcpStream
.The text was updated successfully, but these errors were encountered: