pub struct CsvReader { /* private fields */ }Expand description
Zero-copy CSV parser for byte slices.
§Design
CsvReader operates directly on a &[u8] byte slice — no file I/O, no
intermediate String allocation per field during the scan phase. Fields
are referenced as sub-slices of the original input and parsed in a single
pass.
§Type inference
Each column’s type is inferred from the first data row:
- All digits (optionally signed, one optional
.) →Float - All digits (optionally signed, no
.) →Int(but stored asFloatfor numeric safety — explicitIntcolumns can be forced viaCsvConfig) "true"/"false"/"1"/"0"→Bool- Anything else →
Str
§Example
ⓘ
let csv = b"name,age,score\nAlice,30,9.5\nBob,25,8.1";
let df = CsvReader::new(CsvConfig::default()).parse(csv)?;
assert_eq!(df.nrows(), 2);Implementations§
Auto Trait Implementations§
impl Freeze for CsvReader
impl RefUnwindSafe for CsvReader
impl Send for CsvReader
impl Sync for CsvReader
impl Unpin for CsvReader
impl UnsafeUnpin for CsvReader
impl UnwindSafe for CsvReader
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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