Splitter

Struct Splitter 

Source
pub struct Splitter<R> { /* private fields */ }
Expand description

An already configured CSV record splitter.

§Configuration

To configure a Splitter, if you need a custom delimiter for instance of if you want to tweak the size of the inner buffer. Check out the SplitterBuilder.

Implementations§

Source§

impl<R: Read> Splitter<R>

Source

pub fn from_reader(reader: R) -> Self

Create a new splitter with default configuration using the provided reader implementing std::io::Read.

Source

pub fn has_headers(&self) -> bool

Returns whether this reader has been configured to interpret the first record as a header.

Source

pub fn byte_headers(&mut self) -> Result<&[u8]>

Attempt to return a reference to this splitter’s first record.

Source

pub fn count_records(&mut self) -> Result<u64>

Consume the reader completely to count the number of records as fast as possible.

Source

pub fn split_record(&mut self) -> Result<Option<&[u8]>>

Attempt to split the next CSV record and return an optional reference to its byte slice.

Returns Ok(None) when the reader is fully consumed.

Source

pub fn split_record_with_position(&mut self) -> Result<Option<(u64, &[u8])>>

Attempt to split the next CSV record and return an optional byte offset as well as a reference to its byte slice.

Returns Ok(None) when the reader is fully consumed.

Source

pub fn into_bufreader(self) -> (Option<Vec<u8>>, BufReader<R>)

Unwrap into an optional first record (only when the reader was configured not to interpret the first record as a header, and when the first record was pre-buffered but not yet reemitted), and the underlying BufReader.

Source

pub fn position(&self) -> u64

Returns the current byte offset of the reader in the wrapped stream.

Trait Implementations§

Source§

impl<R: Debug> Debug for Splitter<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for Splitter<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Splitter<R>
where R: RefUnwindSafe,

§

impl<R> Send for Splitter<R>
where R: Send,

§

impl<R> Sync for Splitter<R>
where R: Sync,

§

impl<R> Unpin for Splitter<R>
where R: Unpin,

§

impl<R> UnwindSafe for Splitter<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.