linebuf 0.0.2

The library provides a interface to read a line through a fixed size of buffer
Documentation
  • Coverage
  • 0%
    0 out of 9 items documented0 out of 6 items with examples
  • Size
  • Source code size: 6.65 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.62 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • phynalle/linebuf
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • phynalle

linebuf

The library provides a interface to read a line through a fixed size of buffer

Usage

Add this to your Cargo.toml:

[dependencies]
linebuf = "0.0.1"

And add this to your crate root:

extern crate linebuf

Example

extern crate linebuf;
use linebuf::{Line, LineReader};

let mut reader = LineReader::new(File::open("/path/to/file")?);
let mut buf = vec![0; 1024];
loop {
  match reader.try_read_line(&mut buf)? {
    Line::Return(0) => break, // EOF
    Line::Return(n) => {
      // reading data reached the `carriage return`(\n)
      ...
    }
    Line::More(n) => {
      // In this time, the data doesn't reached the end of line
      ...
    }
  }
}