pub struct CsvItemReaderBuilder { /* private fields */ }

Implementations§

source§

impl CsvItemReaderBuilder

Create a new builder for configuring CSV parsing.

To convert a builder into a reader, call one of the methods starting with from_.

Example

use std::error::Error;
use csv::{ReaderBuilder, StringRecord};

fn example() -> Result<(), Box<dyn Error>> {
    let data = "\
city,country,pop
Boston,United States,4628910
Concord,United States,42695
";
    let mut rdr = ReaderBuilder::new().from_reader(data.as_bytes());

    let records = rdr
        .records()
        .collect::<Result<Vec<StringRecord>, csv::Error>>()?;
    assert_eq!(records, vec![
        vec!["Boston", "United States", "4628910"],
        vec!["Concord", "United States", "42695"],
    ]);
    Ok(())
}
source

pub fn new() -> CsvItemReaderBuilder

source

pub fn delimiter(self, delimiter: u8) -> CsvItemReaderBuilder

source

pub fn terminator(self, terminator: Terminator) -> CsvItemReaderBuilder

source

pub fn has_headers(self, yes: bool) -> CsvItemReaderBuilder

source

pub fn from_reader<R: Read>(self, rdr: R) -> CsvItemReader<R>

source

pub fn from_path<R: AsRef<Path>>(self, path: R) -> CsvItemReader<File>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.