#unicode #char #reader

char_reader

Safely read wild streams as chars or lines

1 unstable release

0.1.0 Nov 4, 2020

#8 in #char

Download history 282/week @ 2021-02-21 339/week @ 2021-02-28 315/week @ 2021-03-07 204/week @ 2021-03-14 138/week @ 2021-03-21 118/week @ 2021-03-28 132/week @ 2021-04-04 161/week @ 2021-04-11 178/week @ 2021-04-18 373/week @ 2021-04-25 197/week @ 2021-05-02 254/week @ 2021-05-09 233/week @ 2021-05-16 330/week @ 2021-05-23 312/week @ 2021-05-30 154/week @ 2021-06-06

953 downloads per month
Used in 2 crates

MIT license

13KB
213 lines

CharReader is a buffered reader with some difference with the standard one:

  • you can read lines without chocking on an infinite stream without newlines
  • you can read lines and not store more than necessary

It's suitable when you'd like to read UTF8 lines and aren't sure the data are kind enough.

You may either read a single char, or read a line.

When reading a line, you pass two parameters:

  • the max number of chars you want to get (rest of line will be dropped)
  • the max number of chars before giving out with an error (thus protecting against infinite streams)

All errors are io::Error:

  • UTF8 errors are of kind InvalidData
  • Lines exceeding your threshold are of kind Other

lib.rs:

CharReader is a buffered reader with some difference with the standard one:

  • you can read lines without chocking on an infinite stream without newlines
  • you can read lines and not store more than necessary

It's suitable when you'd like to read UTF8 lines and aren't sure the data are kind enough.

You may either read a single char, or read a line.

When reading a line, you pass two parameters:

  • the max number of chars you want to get (rest of line will be dropped)
  • the max number of chars before giving out with an error (thus protecting against infinite streams)

All errors are io::Error:

  • UTF8 errors are of kind InvalidData
  • Lines exceeding your threshold are of kind Other

No runtime deps