pub struct Reader { /* private fields */ }Expand description
Parses CSV data from a byte slice or a std::io::Read source.
Create an iterator over rows with Reader::rows:
let data = b"name,age\nAlice,30\nBob,25\n";
for row in Reader::new(data).rows() {
let row = row?;
// ...
}Implementations§
Source§impl Reader
impl Reader
Sourcepub fn new(data: &[u8]) -> Self
pub fn new(data: &[u8]) -> Self
Create a reader from a byte slice. The data is copied into
an internal buffer. This constructor is available with or
without the std feature.
Sourcepub fn set_delimiter(&mut self, byte: u8) -> &mut Self
pub fn set_delimiter(&mut self, byte: u8) -> &mut Self
Set the field delimiter byte (default is ,).
Sourcepub fn set_flexible(&mut self, yes: bool) -> &mut Self
pub fn set_flexible(&mut self, yes: bool) -> &mut Self
Allow variable numbers of fields per row (default false).
Source§impl Reader
impl Reader
Sourcepub fn from_reader(reader: impl Read + 'static) -> Self
pub fn from_reader(reader: impl Read + 'static) -> Self
Create a reader from any std::io::Read source. Data is streamed
in chunks as rows are read, without loading the entire input.
§Example
let file = File::open("data.csv").unwrap();
for row in Reader::from_reader(file).rows() {
let row = row?;
// ...
}Auto Trait Implementations§
impl !RefUnwindSafe for Reader
impl !Send for Reader
impl !Sync for Reader
impl !UnwindSafe for Reader
impl Freeze for Reader
impl Unpin for Reader
impl UnsafeUnpin for Reader
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