pub struct ReaderLineBuffer<R: Read> {
inner: Mutex<ReaderLineBufferInner<R>>,
}Expand description
A line-buffered reader backed by a circular buffer.
Reads lines from an io::Read source, stores them in a fixed-size
circular buffer, and optionally calls a callback for each line.
Fields§
§inner: Mutex<ReaderLineBufferInner<R>>Implementations§
Source§impl<R: Read> ReaderLineBuffer<R>
impl<R: Read> ReaderLineBuffer<R>
Sourcepub fn new(reader: R, max_lines: usize) -> Self
pub fn new(reader: R, max_lines: usize) -> Self
Create a new ReaderLineBuffer wrapping the given reader.
max_lines specifies the circular buffer capacity.
If 0, defaults to 1000.
Sourcepub fn set_line_callback<F>(&self, callback: F)
pub fn set_line_callback<F>(&self, callback: F)
Set a callback that is invoked for each line read.
Sourcepub fn read_line(&self) -> Result<String>
pub fn read_line(&self) -> Result<String>
Read the next line from the underlying reader.
Returns Ok(line) for each line, or Err(io::ErrorKind::UnexpectedEof)
when the reader is exhausted.
Sourcepub fn get_line_count(&self) -> usize
pub fn get_line_count(&self) -> usize
Get the number of lines currently in the buffer.
Sourcepub fn get_total_line_count(&self) -> usize
pub fn get_total_line_count(&self) -> usize
Get the total number of lines read (may exceed buffer capacity).
Auto Trait Implementations§
impl<R> !Freeze for ReaderLineBuffer<R>
impl<R> RefUnwindSafe for ReaderLineBuffer<R>
impl<R> Send for ReaderLineBuffer<R>where
R: Send,
impl<R> Sync for ReaderLineBuffer<R>where
R: Send,
impl<R> Unpin for ReaderLineBuffer<R>where
R: Unpin,
impl<R> UnwindSafe for ReaderLineBuffer<R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.