Skip to content

Move BufferedReader::{read_until, read_line} somewhere else #10334

Closed
@sfackler

Description

@sfackler

These methods were originally implemented on BufferedReader because they require a call to read for each byte if they're implemented naively. However, BufferedReader isn't the only type for which this can be done efficiently. At the very least, MemReader and BufReader have obvious fast implementations. One can imagine other Reader implementations that are just proxies for an inner implementation and log data usage or whatever where read_until will be fast if it's fast on the underlying Reader.

I figure we can either add the methods to Reader with a warning saying "this will be really slow on certain Readers" or split these methods off onto a separate interface that's implemented by things that can do these efficiently. The second option puts a larger burden on library authors but will probably save people from wondering why read_line is slow when called on a TcpStream.

cc @alexcrichton

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions