pub struct FileDecompressor {
pub lines_consumed: usize,
/* private fields */
}Expand description
State for incremental zstd decompression and line extraction from a single file.
Fields§
§lines_consumed: usizeGlobal line index up to which lines have been consumed or skipped. This is the value that should be used for checkpointing. Equals skip_before + number of lines actually returned to caller.
Implementations§
Source§impl FileDecompressor
impl FileDecompressor
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open a file and prepare for incremental zstd decompression.
Sourcepub fn open_with_max_line_size(
path: &Path,
max_out_buffer: usize,
) -> Result<Self>
pub fn open_with_max_line_size( path: &Path, max_out_buffer: usize, ) -> Result<Self>
Open a file, capping the output buffer at max_out_buffer bytes. A
record that fills the cap without a newline is discarded and reading
continues with the next record (see NextLine::Skipped).
Sourcepub fn next_line(&mut self, skip_before: usize) -> Result<NextLine>
pub fn next_line(&mut self, skip_before: usize) -> Result<NextLine>
Returns the next line from this file.
skip_before: lines with index < skip_before are discarded.
Returns:
Ok(NextLine::Line(line))– a complete line was extracted.Ok(NextLine::Skipped { .. })– a record exceeding the maximum line size was discarded. Reading continues with the next record.Ok(NextLine::None)– there isn’t any more data available right now. The caller should check if the file is done or retry later.
Sourcepub fn reset_eof(&mut self)
pub fn reset_eof(&mut self)
Reset the EOF flag so we can try reading more data (useful when tailing a file that is still being written to).
Sourcepub fn has_partial_data(&self) -> bool
pub fn has_partial_data(&self) -> bool
Returns true if there is partial (incomplete line) data remaining: either buffered bytes with no terminating newline yet, or a record still being discarded for exceeding the maximum line size. When a done file ends in this state the trailing record is incomplete and is dropped.
Sourcepub fn is_discarding_oversized_record(&self) -> bool
pub fn is_discarding_oversized_record(&self) -> bool
Returns true if the trailing partial data is a record being discarded for exceeding the maximum line size, as opposed to an unterminated line left behind by a writer that exited without flushing.
Auto Trait Implementations§
impl Freeze for FileDecompressor
impl RefUnwindSafe for FileDecompressor
impl Send for FileDecompressor
impl Sync for FileDecompressor
impl Unpin for FileDecompressor
impl UnwindSafe for FileDecompressor
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more