Struct uu_tail::chunks::LinesChunk
source · pub struct LinesChunk { /* private fields */ }Expand description
Works similar to a BytesChunk but also stores the number of lines encountered in the current
buffer. The size of the buffer is limited to a fixed size number of bytes.
Implementations§
source§impl LinesChunk
impl LinesChunk
pub fn new(delimiter: u8) -> Self
sourcepub fn get_buffer(&self) -> &[u8] ⓘ
pub fn get_buffer(&self) -> &[u8] ⓘ
Returns this buffer safely. See BytesChunk::get_buffer
returns: &u8 with length self.bytes
sourcepub fn get_buffer_with(&self, offset: usize) -> &[u8] ⓘ
pub fn get_buffer_with(&self, offset: usize) -> &[u8] ⓘ
Returns this buffer safely with an offset applied. See BytesChunk::get_buffer_with.
returns: &u8 with length self.bytes - offset
sourcepub fn get_lines(&self) -> usize
pub fn get_lines(&self) -> usize
Return the number of lines the buffer contains. self.lines needs to be set before the call
to this function returns the correct value. If the calculation of lines is needed then
use self.count_lines.
sourcepub fn fill(&mut self, filehandle: &mut impl BufRead) -> UResult<Option<usize>>
pub fn fill(&mut self, filehandle: &mut impl BufRead) -> UResult<Option<usize>>
Fills self.buffer with maximal BUFFER_SIZE number of bytes, draining the reader by
that number of bytes. This function works like the BytesChunk::fill function besides
that this function also counts and stores the number of lines encountered while reading from
the filehandle.