[][src]Trait simple_lines::ReadExt

pub trait ReadExt {
    type Read: Read;
    pub fn lines_rc_with_capacity(
        self,
        buffer_capacity: usize
    ) -> RcLineIterator<Self::Read>;
pub fn lines_rc(self) -> RcLineIterator<Self::Read>; }

Extensions to std::io::Read to implement simple and secure line iterators

Associated Types

type Read: Read[src]

Underlying Reader

Loading content...

Required methods

pub fn lines_rc_with_capacity(
    self,
    buffer_capacity: usize
) -> RcLineIterator<Self::Read>
[src]

Creates a RcLineIterator with a custom buffer capacity

pub fn lines_rc(self) -> RcLineIterator<Self::Read>[src]

Creates a RcLineIterator with the default capacity of 64kb

Examples

use simple_lines::ReadExt;

let cursor = std::io::Cursor::new("12345678\r\n123");
let mut lines = cursor.lines_rc_with_capacity(5);
if let simple_lines::Error::Incomplete(x) = lines.next().unwrap().unwrap_err() {
    assert_eq!(*x, "12345");
} else {
    panic!("Expected incomplete if EOL was not detected");
}
if let simple_lines::Error::Incomplete(x) = lines.next().unwrap().unwrap_err() {
    assert_eq!(*x, "678");
} else {
    panic!("Expected incomplete line for the rest");
}
assert_eq!(*lines.next().unwrap().unwrap(), "123");
Loading content...

Implementors

impl<T: Read> ReadExt for T[src]

type Read = T

Loading content...