Crate lines [] [src]

Utilities for iterating readers efficiently line-by-line over ASCII or UTF-8 encoded text content. Lines are identified by a LINE-FEED, i.e. a byte with the value \x0A. Content at the end of a stream will be considered as a line - no matter whether it was termined by a line-feed or not.

Efficiency is achieved by two limitations:

  • The provided utilities avoid allocation of memory for each identified line by reusing internal buffers. Clients are supposed to make their own copy of a line if it needs to be remembered for later use in the program.

  • The provided utilities do not validate proper encoding of the input data, and leave this up to the client.

Modules

linemapper

Implements line-by-line iteration over a given reader by mapping a user defined function over each line.

linereader

Iterates over lines of a given reader by keeping an internal buffer which client code is handed a reference to for consumption of the line.

Macros

read_lines

Provides a convenient way to iterate over all lines through a LineReader. For an example, refer to the documentation of LineReader. The identifier representing the read line will be of type Result<&[u8]>.

try_read_lines

Provides a convenient way to iterate over all lines through a LineReader wrapping the invocation to LineReader::read_line with a try!. Hence, the identifer representing the read line will be directly of type &[u8].