csv_core

Struct ReaderBuilder

Source
pub struct ReaderBuilder { /* private fields */ }
Expand description

Builds a CSV reader with various configuration knobs.

This builder can be used to tweak the field delimiter, record terminator and more for parsing CSV. Once a CSV Reader is built, its configuration cannot be changed.

Implementations§

Source§

impl ReaderBuilder

Source

pub fn new() -> ReaderBuilder

Create a new builder.

Source

pub fn build(&self) -> Reader

Build a CSV parser from this configuration.

Source

pub fn delimiter(&mut self, delimiter: u8) -> &mut ReaderBuilder

The field delimiter to use when parsing CSV.

The default is b','.

Source

pub fn terminator(&mut self, term: Terminator) -> &mut ReaderBuilder

The record terminator to use when parsing CSV.

A record terminator can be any single byte. The default is a special value, Terminator::CRLF, which treats any occurrence of \r, \n or \r\n as a single record terminator.

Source

pub fn quote(&mut self, quote: u8) -> &mut ReaderBuilder

The quote character to use when parsing CSV.

The default is b'"'.

Source

pub fn escape(&mut self, escape: Option<u8>) -> &mut ReaderBuilder

The escape character to use when parsing CSV.

In some variants of CSV, quotes are escaped using a special escape character like \ (instead of escaping quotes by doubling them).

By default, recognizing these idiosyncratic escapes is disabled.

Source

pub fn double_quote(&mut self, yes: bool) -> &mut ReaderBuilder

Enable double quote escapes.

This is enabled by default, but it may be disabled. When disabled, doubled quotes are not interpreted as escapes.

Source

pub fn quoting(&mut self, yes: bool) -> &mut ReaderBuilder

Enable or disable quoting.

This is enabled by default, but it may be disabled. When disabled, quotes are not treated specially.

Source

pub fn comment(&mut self, comment: Option<u8>) -> &mut ReaderBuilder

The comment character to use when parsing CSV.

If the start of a record begins with the byte given here, then that line is ignored by the CSV parser.

This is disabled by default.

Source

pub fn ascii(&mut self) -> &mut ReaderBuilder

A convenience method for specifying a configuration to read ASCII delimited text.

This sets the delimiter and record terminator to the ASCII unit separator (\x1F) and record separator (\x1E), respectively.

Trait Implementations§

Source§

impl Debug for ReaderBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ReaderBuilder

Source§

fn default() -> ReaderBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.