Skip to main content

Reader

Struct Reader 

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

A CSV file, positioned at a record boundary.

Implementations§

Source§

impl Reader

Source

pub fn open(file: Box<dyn File>, path: &str) -> Result<Self>

Opens a file, works out how it is written, and positions it at the first row.

The path is kept because the error a bad value produces names it, the way DuckDB’s does.

§Errors

When the file cannot be read, and when the first block of it does not hold one whole record, which is a single line longer than a megabyte and is not a CSV file anybody meant to write.

Source

pub fn fields(&self) -> Vec<Field>

The columns this reader will produce, in order.

Source

pub fn project(&mut self, columns: &[usize]) -> Result<()>

Reads only these columns, by position in the file, in this order.

§Errors

When a position is past the end of the file’s columns.

Source

pub const fn dialect(&self) -> Dialect

How this file is punctuated, which is what the sniffer decided.

Source

pub fn next_chunk(&mut self) -> Result<Option<Chunk>>

The next chunk, or None at the end of the file.

§Errors

A read error, a malformed record, or a value that does not fit the type the sample chose for its column.

Trait Implementations§

Source§

impl Debug for Reader

Source§

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

Formats the value using the given formatter. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.