Giter Site home page Giter Site logo

rust-csv's Introduction

csv

A fast and flexible CSV reader and writer for Rust, with support for Serde.

Build status crates.io

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/csv

If you're new to Rust, the tutorial is a good place to start.

Usage

To bring this crate into your repository, either add csv to your Cargo.toml, or run cargo add csv.

Example

This example shows how to read CSV data from stdin and print each record to stdout.

There are more examples in the cookbook.

use std::{error::Error, io, process};

fn example() -> Result<(), Box<dyn Error>> {
    // Build the CSV reader and iterate over each record.
    let mut rdr = csv::Reader::from_reader(io::stdin());
    for result in rdr.records() {
        // The iterator yields Result<StringRecord, Error>, so we check the
        // error here.
        let record = result?;
        println!("{:?}", record);
    }
    Ok(())
}

fn main() {
    if let Err(err) = example() {
        println!("error running example: {}", err);
        process::exit(1);
    }
}

The above example can be run like so:

$ git clone git://github.com/BurntSushi/rust-csv
$ cd rust-csv
$ cargo run --example cookbook-read-basic < examples/data/smallpop.csv

Example with Serde

This example shows how to read CSV data from stdin into your own custom struct. By default, the member names of the struct are matched with the values in the header record of your CSV data.

use std::{error::Error, io, process};

#[derive(Debug, serde::Deserialize)]
struct Record {
    city: String,
    region: String,
    country: String,
    population: Option<u64>,
}

fn example() -> Result<(), Box<dyn Error>> {
    let mut rdr = csv::Reader::from_reader(io::stdin());
    for result in rdr.deserialize() {
        // Notice that we need to provide a type hint for automatic
        // deserialization.
        let record: Record = result?;
        println!("{:?}", record);
    }
    Ok(())
}

fn main() {
    if let Err(err) = example() {
        println!("error running example: {}", err);
        process::exit(1);
    }
}

The above example can be run like so:

$ git clone git://github.com/BurntSushi/rust-csv
$ cd rust-csv
$ cargo run --example cookbook-read-serde < examples/data/smallpop.csv

rust-csv's People

Contributors

aedoq avatar alexchandel avatar amilajack avatar aochagavia avatar benesch avatar brandonw avatar burntsushi avatar ebfe avatar eclipseo avatar evinrobertson avatar fhartwig avatar golddranks avatar huonw avatar ian-hamlin avatar ignatenkobrain avatar jturner314 avatar mbrubeck avatar medwards avatar michalsrb avatar mlodato517 avatar mschmo avatar mwilbur avatar ntr-808 avatar owst avatar paulkernfeld avatar stuarth avatar ten0 avatar timhabermaas avatar wildcryptofox avatar zsiciarz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-csv's Issues

Request: Optional header support for serialize nested struct

May I ask if it is possible for an option to serialize struct that contains array / tuple / struct?

Previously in Python I use a flatten function to convert a nested dictionary to a flat dictionary, with field combined and seperated by some seperator (e.g. "velocity.0"), but right now serializing map or nested struct with header is not supported now.

Therefore, I would like to wish for a way to optionally serialize nested struct header with user provided seperator.

investigate alternative parsing architecture: keep entire record in memory at once

Provoked by #31, the current parser hangs on to exactly one field while parsing. This means that in order to read an entire record into memory, you must at least clone each field returned by the core next_bytes method. This is the optimal strategy when your task can be formulated as a simple state machine over the data that doesn't need to look at the entire record at once. But if you do need to look at the whole record, you'll need to clone each field which can be costly.

Instead, we should investigate providing a parser that works like the current one, but hangs on to a record at a time. It would never emit a "field" event. Instead, it would only emit a "record" event that returns a borrowed slice into its internal buffer. This would be overwritten on the next parsing call.

This should actually improve performance for the "normal" cases like when one uses records().

Implement std conversion traits for Writer when appropriate

Writer<Vec<u8>> could trivially implement Into<String>, Into<Vec<u8>>, AsRef<str> and AsRef<[u8]>, but doesn't. This would be good for generic programming, since taking an &T where T: AsRef<Foo>, or a T where T: Into<Foo> are extremely commmon idioms in Rust.

Expose &mut Reader<R>

This issue came up whilst discussing an particular error on IRC #rust. One person (eddyb) suggested that "DecodedRecords, StringRecords and ByteRecords could all expose their &mut Reader<R> with some builtin 'inner' method". You can see the IRC log over at The relevant IRC log can be seen over at https://botbot.me/mozilla/rust/2014-12-28/?msg=28424193&page=22.

Furthermore, this issue came about when discussing how to fix this particular gist: https://gist.github.com/JP-Ellis/5490826d9e12de07b273.

SIMD support

Would SIMD support on Rust nightly be a goal of the project?
I notice that csvmonkey took the lead on the shootout with SIMD support, so this could make up the difference.

use serde

I should start using serde for the automatic serialization component of this crate.

I don't think this means removing support for rustc-serialize just yet though.

Support serde deserialization

Rustc is nice but many library's are moving toward serde interfaces. It would be nice to have some serde support for decoding here

Single column CSV is unparseable

Hi, according to RFC 4180 a csv file that has one column without commas on the end is valid CSV file.

But how can I make reader read such file? Reader needs delimiter or defaults to b',', how can I pass there no delimiter?

It's a freaking edge case, thats drives me mad :/

Feature Request: Record parsing based on field names

I deal with CSVs with tons of extra columns, which exist for good reason, mostly debugging, but which I don't need for the average case processing. It would be incredibly tedious and brittle to write a tuple or record which contains a field for every column for every CSV schema I work with. Would it be possible to use struct field names along with a header row to only extract columns that are fields of the struct? That is, given a CSV with header A,B,C,D and a struct as below

struct Rec {
    u32 A,
    u32 B,
    i32 D
}

would it be possible to use the macro system to only decode columns A, B, and D, and omit column C?

UTF-8 byte order mark can cause incorrect parsing

I can't find a way to configure the parser to correctly process CSV file, which starts with UTF-8 byte order mark (0xEF, 0xBB, 0xBF) followed by comment character ('#' in this case).

Sample file bom_csv.zip

Priority is low, it is simple enough to strip BOM from parser's input.

How to change floating point precision?

How can I change the precision of floating point numbers written to the file? For example, I obtain the result 2.0000000002, 2.0000000002, while it should be 2.000000000200, 2.000000000201.

The code below shows the issue:

extern crate csv;

fn main() {
    let mut wtr = csv::Writer::from_memory();
    let a = 2.000000000200f64;
    let b = 2.000000000201f64;
    let result = wtr.encode((a,b));
    assert!(result.is_ok());
    let f = format!("{},{}\n", a, b);
    println!("{}", f);
    println!("{}", wtr.as_string());
    assert_eq!(wtr.as_string(), f);
// thread '<main>' panicked at 'assertion failed: `(left == right)` (left: `"2.0000000002,2.0000000002\n"`, right: `"2.0000000002,2.000000000201\n"`)', src/main.rs:12
}

Example from docs fails to build

I found that copy/pasting right from the example documentation fails to build:

error[E0599]: no method named `write_record` found for type `csv::Writer<std::io::Stdout>` in the current scope
  --> src/main.rs:12:9

12 |     wtr.write_record(&["city", "region", "country", "population"])?;

Thanks

how to read this csv file?

ๅง“ๅ, ๆ€งๅˆซ, ๅนด็บช, ๅˆ†ๆ•ฐ, ็ญ‰็บง
็Ž‹ๅฐไบŒ, ็”ท, 12, 88, ่‰ฏๅฅฝ
็Ž‹ๅฐไธ‰, ็”ท, 13, 89, ่‰ฏๅฅฝ
็Ž‹ๅฐๅ››, ็”ท, 14, 91, ไผ˜็ง€

thanks.

method `detail` is not a member of trait `StdError`

Just upgraded my nightly rust to the 2015-1-23 build, and now running into compilation errors on one of my projects:

   Compiling csv v0.12.9
/Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.12.9/src/lib.rs:317:5: 317:66 error: method `detail` is not a member of trait `StdError`
/Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.12.9/src/lib.rs:317     fn detail(&self) -> Option<String> { Some(self.to_string()) }
                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `csv`.

This sounds like it's related to rust-lang/rust@3cb9fa2 . I tried just deleting the detail method indicated by the error message (since cause was already implemented, and the RFC made it sound like that's what it turned into), but that led to another problem that I didn't understand. So I gave up.

But here's an issue, anyway.

Support for line comments?

Yes, CSV is a terrible format and no, there is no official way to denote comments in CSV files but it is terribly common to do so. Having another chained method to denote a line prefix that should cause a line to be skipped would be valuable, e.g.

csv::Reader::from_string(my_csv_string).has_headers(false).delimiter(b'\t').comment_char('#')

I tried adding this myself and submitting a PR but my rust is nowhere near good enough for that kind of bravado.

read from socket

Let's say i have a source sending me csv formatted data via tcp. Is there a nice way to feed it into rust-csv (i.e. not by writing it into file and reading it again)?

Why bump instead of bump_eor in StartRecord state?

Here You have

StartRecord => {
    if self.is_record_term(c) {
        self.bump();
    } else {
        self.state = StartField;
    }
}

but everywhere else that you have a is_record_term you do a bump_eor, which as far as I know is needed to skip \n in the special case of \r\n.

So what I'm wondering is there some reason you wouldn't want to skip the \n? Am I missing the point, or is this a bug?

Best way to have csv::Reader ignore certain fields

Is there an efficient way to only read the first n fields?

For example, if the user only wants 1 field, the API allows:

rdr.decode().map(|x| x.unwrap())
    .map(|(tagname, _): (String, Vec<String>)| tagname)
    .collect()

But this still allocates a vector of strings for the tail, which is never read. Is there a better way?

Feature Request: DictReader DictWriter like python

Rust newbie here. Please point if i missed it in documentation or there is a preferred way of achieving python's DictReader DictWriter behavior if available. If not, is this something that can be added to lib.

Line ending not in compliance with RFC 4180

The documentation for csv::Writer claims that it generates RFC 4180 compliant files with the exception of emply single record fields.

The RFC suggests a definition for CSV which specifies CRLF line endings (i.e. \r\n). However I note the default configuration in csv::Writer is actually for the single byte \n.

Resolution of this issue can be either updating the documentation to note this additional devitation from the definition suggested in the RFC or changing the default to CRLF.

Bad cargo configuration in README.md

README.md says to add to Cargo.toml:

[dependencies.rust-csv]
git = "git://github.com/BurntSushi/rust-csv"

but it should be

[dependencies.csv]
git = "git://github.com/BurntSushi/rust-csv"

i.e. the dependency is csv and not rust-csv.

Request: csv::Writer::has_headers

When encoding structs, it would be very useful to tell the writer to write a header line before the other content, similar to how csv::Reader`` hashas_headers```. Right now, I am adding it manually and thereby am duplicating the struct keys, which I fear will cause bugs when new fields are added later and someone forgets to update the header string.
What do you think about adding this?

I ran into a build error after updating rust

This is using: rustc 0.13.0-nightly (126db549b 2014-12-15 00:07:35 +0000)

โ‡’ cargo update
Updating git repository git://github.com/BurntSushi/rust-csv
โ‡’ cargo build
Compiling csv v0.7.4 (git://github.com/BurntSushi/rust-csv#aa9547fd)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:72:5: 75:6 error: method emit_enum has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:72 fn emit_enum(&mut self, _: &str, f: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:73 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:74 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:75 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:76:5: 86:6 error: method emit_enum_variant has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:76 fn emit_enum_variant(&mut self, v_name: &str, _: uint, len: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:77 f: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:78 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:79 match len {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:80 0 => self.push_string(v_name),
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:81 1 => f(self),
...
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:87:5: 91:6 error: method emit_enum_variant_arg has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:87 fn emit_enum_variant_arg(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:88 f: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:89 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:90 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:91 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:92:5: 96:6 error: method emit_enum_struct_variant has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:92 fn emit_enum_struct_variant(&mut self, v_name: &str, v_id: uint, len: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:93 f: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:94 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:95 self.emit_enum_variant(v_name, v_id, len, f)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:96 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:97:5: 102:6 error: method emit_enum_struct_variant_field has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:97 fn emit_enum_struct_variant_field(&mut self, _: &str, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:98 _: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:99 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:100 Err(Error::Encode("Cannot encode enum
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:101 variants with arguments.".to_string()))
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:102 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:103:5: 106:6 error: method emit_struct has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:103 fn emit_struct(&mut self, _: &str, len: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:104 f: |&mut Encoded| -> CsvResult<()>) -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:105 self.emit_seq(len, f)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:106 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:107:5: 111:6 error: method emit_struct_field has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:107 fn emit_struct_field(&mut self, _: &str, f_idx: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:108 f: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:109 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:110 self.emit_seq_elt(f_idx, f)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:111 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:112:5: 115:6 error: method emit_tuple has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:112 fn emit_tuple(&mut self, len: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:113 f: |&mut Encoded| -> CsvResult<()>) -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:114 self.emit_seq(len, f)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:115 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:116:5: 120:6 error: method emit_tuple_arg has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:116 fn emit_tuple_arg(&mut self, idx: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:117 f: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:118 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:119 self.emit_seq_elt(idx, f)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:120 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:121:5: 125:6 error: method emit_tuple_struct has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:121 fn emit_tuple_struct(&mut self, _: &str, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:122 _: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:123 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:124 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:125 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:126:5: 130:6 error: method emit_tuple_struct_arg has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:126 fn emit_tuple_struct_arg(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:127 _: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:128 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:129 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:130 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:131:5: 134:6 error: method emit_option has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:131 fn emit_option(&mut self, f: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:132 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:133 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:134 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:138:5: 141:6 error: method emit_option_some has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:138 fn emit_option_some(&mut self, f: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:139 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:140 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:141 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:142:5: 146:6 error: method emit_seq has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:142 fn emit_seq(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:143 f: |this: &mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:144 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:145 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:146 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:147:5: 151:6 error: method emit_seq_elt has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:147 fn emit_seq_elt(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:148 f: |this: &mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:149 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:150 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:151 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:152:5: 155:6 error: method emit_map has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:152 fn emit_map(&mut self, _: uint, _: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:153 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:154 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:155 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:156:5: 160:6 error: method emit_map_elt_key has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:156 fn emit_map_elt_key(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:157 _: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:158 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:159 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:160 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:161:5: 165:6 error: method emit_map_elt_val has 0 type parameters but its trait declaration has 1 type parameter [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:161 fn emit_map_elt_val(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:162 _: |&mut Encoded| -> CsvResult<()>)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:163 -> CsvResult<()> {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:164 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:165 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:95:14: 95:53 error: the trait core::ops::Fn<(&mut encoder::Encoded,), core::result::Result<(), Error>> is not implemented for the type |&mut encoder::Encoded| -> core::result::Result<(), Error>
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:95 self.emit_enum_variant(v_name, v_id, len, f)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:105:14: 105:30 error: the trait core::ops::Fn<(&mut encoder::Encoded,), core::result::Result<(), Error>> is not implemented for the type |&mut encoder::Encoded| -> core::result::Result<(), Error>
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:105 self.emit_seq(len, f)
^~~~~~~~~~~~~~~~
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:110:14: 110:36 error: the trait core::ops::Fn<(&mut encoder::Encoded,), core::result::Result<(), Error>> is not implemented for the type |&mut encoder::Encoded| -> core::result::Result<(), Error>
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:110 self.emit_seq_elt(f_idx, f)
^~~~~~~~~~~~~~~~~~~~~~
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:114:14: 114:30 error: the trait core::ops::Fn<(&mut encoder::Encoded,), core::result::Result<(), Error>> is not implemented for the type |&mut encoder::Encoded| -> core::result::Result<(), Error>
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:114 self.emit_seq(len, f)
^~~~~~~~~~~~~~~~
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:119:14: 119:34 error: the trait core::ops::Fn<(&mut encoder::Encoded,), core::result::Result<(), Error>> is not implemented for the type |&mut encoder::Encoded| -> core::result::Result<(), Error>
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/encoder.rs:119 self.emit_seq_elt(idx, f)
^~~~~~~~~~~~~~~~~~~~
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:103:5: 107:6 error: method read_enum has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:103 fn read_enum(&mut self, _: &str,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:104 f: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:105 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:106 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:107 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:108:5: 147:6 error: method read_enum_variant has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:108 fn read_enum_variant(&mut self, names: &[&str],
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:109 f: |&mut Decoded, uint| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:110 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:111 let variant = to_lower(try!(self.pop_string()).as_slice());
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:112
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:113 // This is subtly broken. Supporting both zero-parameter and
...
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:148:5: 152:6 error: method read_enum_variant_arg has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:148 fn read_enum_variant_arg(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:149 f: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:150 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:151 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:152 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:153:5: 157:6 error: method read_enum_struct_variant has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:153 fn read_enum_struct_variant(&mut self, names: &[&str],
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:154 f: |&mut Decoded, uint| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:155 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:156 self.read_enum_variant(names, f)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:157 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:158:5: 162:6 error: method read_enum_struct_variant_field has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:158 fn read_enum_struct_variant_field(&mut self, _: &str, f_idx: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:159 f: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:160 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:161 self.read_enum_variant_arg(f_idx, f)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:162 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:163:5: 171:6 error: method read_struct has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:163 fn read_struct(&mut self, s_name: &str, len: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:164 f: |&mut Decoded| -> CsvResult) -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:165 if self.len() < len {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:166 return self.err(
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:167 format!("Struct '{}' has {} fields but current record
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:168 has {} fields.", s_name, len, self.len()));
...
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:172:5: 176:6 error: method read_struct_field has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:172 fn read_struct_field(&mut self, _: &str, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:173 f: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:174 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:175 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:176 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:177:5: 180:6 error: method read_tuple has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:177 fn read_tuple(&mut self, _: uint, f: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:178 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:179 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:180 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:181:5: 185:6 error: method read_tuple_arg has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:181 fn read_tuple_arg(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:182 f: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:183 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:184 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:185 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:186:5: 190:6 error: method read_tuple_struct has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:186 fn read_tuple_struct(&mut self, _: &str, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:187 _: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:188 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:189 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:190 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:191:5: 195:6 error: method read_tuple_struct_arg has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:191 fn read_tuple_struct_arg(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:192 _: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:193 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:194 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:195 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:196:5: 209:6 error: method read_option has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:196 fn read_option(&mut self,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:197 f: |&mut Decoded, bool| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:198 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:199 let s = try!(self.pop_string());
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:200 if s.is_empty() {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:201 f(self, false)
...
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:210:5: 214:6 error: method read_seq has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:210 fn read_seq(&mut self, f: |&mut Decoded, uint| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:211 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:212 let len = self.len();
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:213 f(self, len)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:214 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:215:5: 219:6 error: method read_seq_elt has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:215 fn read_seq_elt(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:216 f: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:217 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:218 f(self)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:219 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:220:5: 223:6 error: method read_map has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:220 fn read_map(&mut self, _: |&mut Decoded, uint| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:221 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:222 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:223 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:224:5: 228:6 error: method read_map_elt_key has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:224 fn read_map_elt_key(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:225 _: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:226 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:227 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:228 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:229:5: 233:6 error: method read_map_elt_val has 1 type parameter but its trait declaration has 2 type parameters [E0049]
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:229 fn read_map_elt_val(&mut self, _: uint,
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:230 _: |&mut Decoded| -> CsvResult)
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:231 -> CsvResult {
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:232 unimplemented!()
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:233 }
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:156:14: 156:41 error: the trait core::ops::Fn<(&mut decoder::Decoded, uint), core::result::Result<_, Error>>is not implemented for the type|&mut decoder::Decoded, uint| -> core::result::Result<T, Error>
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:156 self.read_enum_variant(names, f)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:161:14: 161:45 error: the traitcore::ops::Fn<(&mut decoder::Decoded,), core::result::Result<_, Error>>is not implemented for the type|&mut decoder::Decoded| -> core::result::Result<T, Error>
/Users/craig.hills/.cargo/git/checkouts/rust-csv-194e3021b57a7ed3/master/src/decoder.rs:161 self.read_enum_variant_arg(f_idx, f)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 42 previous errors
Could not compilecsv.

To learn more, run the command again with --verbose.

add a "strict" parsing mode

It is occasionally useful to parse CSV in a "strict" mode, where by the parser returns an error if the CSV data is invalid. A use case came up for this on the xsv project: BurntSushi/xsv#79

Normally, adding a "strict" mode to the existing parser would incur a performance hit, but since the parser uses a DFA, we can compile away the case analysis. So what this means, I think, is just adding a few more conditionals to the NFA state machine that causes it to fail when strict mode is enabled and invalid CSV data is seen. Basically, if this doesn't require adding any new states, then this should be as easy as it is to think through the error handling. (If a new state needs to be added, then you need to mess with the DFA transition table sizes to make room for it. And we need to be careful not to increase the table size too much.)

I'd be happy to mentor this.

Is there a number of fields limit?

It seems I have an error when I have 13 fields but not when I have 12. Is there a limit?

doesn't work

fn main() {
    let data = "
a,b,c,d,e,f,g,h,i,j,k,l,m,n
a,b,c,d,e,f,g,h,i,j,k,l,m,n";

    let mut rdr = csv::Reader::from_string(data).has_headers(false);
    for row in rdr.decode() {
        let (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13): (String, String, String, String, String, String, String, String, String, String, String, String, String) = row.unwrap();
        println!("{}", n1);
    }
}
$ cargo run
   Compiling test-csv v0.1.0 (file:///home/bruno/dev/rust/test-csv)
src/main.rs:22:20: 22:26 error: the trait bound `(std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String): rustc_serialize::serialize::Decodable` is not satisfied [E0277]
src/main.rs:22     for row in rdr.decode() {
                                  ^~~~~~
src/main.rs:22:20: 22:26 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:22:5: 25:6 error: the trait bound `(std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String): rustc_serialize::serialize::Decodable` is not satisfied [E0277]
src/main.rs:22     for row in rdr.decode() {
                   ^
src/main.rs:22:5: 25:6 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:22:5: 25:6 note: required because of the requirements on the impl of `std::iter::Iterator` for `csv::DecodedRecords<'_, std::io::Cursor<std::vec::Vec<u8>>, (std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String)>`
error: aborting due to 2 previous errors
error: Could not compile `test-csv`.

works

fn main() {
    let data = "
a,b,c,d,e,f,g,h,i,j,k,l,m
a,b,c,d,e,f,g,h,i,j,k,l,m";

    let mut rdr = csv::Reader::from_string(data).has_headers(false);
    for row in rdr.decode() {
        let (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12): (String, String, String, String, String, String, String, String, String, String, String, String) = row.unwrap();
        println!("{}", n1);
    }
}

Request: multiline records optional

Hello,

could you make multiline records optional? I'm asking because the files I process sometimes contain broken records where a field has open quote but has not closing quote and because of that the parser continues to searching for the end of the field on the next text line in the file. That conforms to CSV standard I know but it could be awesome if you can make that behavior optional.

Changes I suggest are

  1. Add the new function to Reader, e.g. fn multiline(self, yes: bool) -> Reader<R>
  2. By default multiline is set to true and that is what the current framework do.
  3. If multiline is set to false and the end of the field is not found in the current line Reader returns an error.

Writing does not have examples and works unexpectedly

I've been attempting to use this package to treat a CSV file as an ad-hoc database, but writing has given me some trouble.

First, there isn't an example in examples about how to write things.

Second, after reading through the code (which actually has a number of nice examples in the comments), I was surprised to read the following comment:

impl Writer<fs::File> {
    /// Creates a new `Writer` that writes CSV data to the file path given.
    ///
    /// The file is created if it does not already exist and is truncated
    /// otherwise.
    pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Writer<fs::File>> {
        Ok(Writer::from_writer(try!(fs::File::create(path))))
    }
}

Given this, it seems like the only "easy" way to deal with a CSV file as a read/write object is to open the file myself and use another writer implementation to avoid nuking the file. It would be really nice if the writer implementation handled this for me.

Reader::next_str internally takes a mutable borrow

This has basically been described in the comments already:

pub fn next_str(&mut self) -> NextField<str> {
        // This really grates me. Once we call `next_bytes`, we initiate a
        // *mutable* borrow of `self` that doesn't stop until the return value
        // goes out of scope. Since we have to return that value, it will never
        // go out of scope in this function.
        //
        // Therefore, we can't get access to any state information after
        // calling `next_bytes`. But we might need it to report an error.
        //
        // One possible way around this is to use interior mutability...

Would it be hard/tricky/nasty to fix this using interior mutability? Also, what's the best workaround for this in the mean while? Obviously one could clone, but that needlessly kills performance. Does a transmute also work?

edit: transmute works

rust-encoding support

It might be a good idea to think about directly supporting rust-encoding, which is a great library that converts between Unicode strings and raw bytes for a variety of different encodings.

Currently, the CSV parser operates at the byte level, which means that it assumes the source text is ascii compatible. That is, an ASCII byte always corresponds to a character in correspondence with the ASCII character. This is OK for regular ASCII text, UTF-8 and latin-1 I think. But for other encodings, this will fail (and it will probably fail silently by providing an incorrect parse). For this reason, decoding text can't be done after the CSV parser has its way, because it could corrupt the text.

I think the obvious implementation path is to implement std::io::Reader for all types that satisfy encoding::Encoding. Then it can be trivially used with the CSV parser because the raw bytes will be UTF-8 encoded. Come to think of it, @lifthrasiir, does an impl for Reader (and Writer) sound like something that belongs in encoding proper? One possible downside of this approach is that the caller will pay for checking that the string is Unicode when they call records.

An alternative is to demand that users run their CSV data through iconv or something similar.

The trait `serde::ser::Serialize` is not implemented for `csv::ByteRecord`

Hello! I'm trying out the new csv beta release on some of in-house data-munging tools, and it's great.

But I did discover one tiny way to improve the ergonomics:

        // Use `byte_records` to get raw binary data without UTF-8 validation
        // for speed, since we may have enormous numbers of rows and hundreds of
        // columns.
        for row in rdr.byte_records() {
            let mut row = row?;
            let zip = from_utf8(&row[zip_col_idx])
                .chain_err(|| -> Error { "Could not parse zip code as UTF-8".into() })?
                .to_owned();
            row.push_field(self.chunk_for(&zip)?.as_bytes());
            wtr.serialize(&row)?;
        }

The above code has no idea what the columns are in any given record, except for zip_col_idx, which it uses to compute a new column and add it to the output row. But this code fails with:

error[E0277]: the trait bound `csv::ByteRecord: serde::ser::Serialize` is not satisfied
   --> src/zip2010.rs:101:17
    |
101 |             wtr.serialize(&row)?;
    |                 ^^^^^^^^^ the trait `serde::ser::Serialize` is not implemented for `csv::ByteRecord`
    |
    = note: required because of the requirements on the impl of `serde::ser::Serialize` for `&csv::ByteRecord`

This turns up in a lot of places in the API when working with generic CSV tools. I suspect one way to improve this might be to implement Serialize and Deserialize for both ByteRecord and Record.

I might be able to find time sometime soon to put together a PR. But is there a better way to fix this?

Fastest way to read a csv file?

Hi,

I've been "playing" with xsv for a couple days and was please to see it's the fasted csv "kit" I've tried.
So I decided to give Rust and the rust-csv crate a try.

Picking code from the examples, I came up with a simple function that iterates over a file and counts the rows.

It takes about 25 seconds to run on a 7.2M rows file, which is fine.
But I was surprised it's exactly the time it takes xsv to run the following "select" on the same file (no prior "index" was done).

time xsv select -d';' field myfile.csv > field.txt
real    0m24.803s
user    0m9.176s
sys 0m9.336s

I was expecting my loop to run faster for it does pretty much nothing, so I'm thinking I probably missed something (once again, I'm a total Rust beginner).

Here's the code:

extern crate csv;

fn main() {
    let mut cnt = 0;
    let mut rdr = csv::Reader::from_file("myfile.csv").unwrap().delimiter(b';');

    for row in rdr.records() {
        cnt+=1;
    }

    println!("{}",cnt);
}

Is there any faster way to read the file?

Note: I'm not complaining about speed, I'm just surprised xsv can do much more than my simple piece of code in the same time ;)

Build failing with current nightly

With current rust, rust-csv does not build:

/home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.13.2/src/reader.rs:172:37: 172:51 error: the trait `std::ffi::AsOsStr` is not implemented for the type `P` [E0277]

/home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.13.2/src/reader.rs:172 Ok(Reader::from_reader(try!(fs::File::open(path))))

^~~~~~~~~~~~~~

<std macros>:1:1: 6:57 note: in expansion of try!

/home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.13.2/src/reader.rs:172:32: 172:59 note: expansion site

/home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.13.2/src/writer.rs:89:37: 89:53 error: the trait `std::ffi::AsOsStr` is not implemented for the type `P` [E0277]

/home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.13.2/src/writer.rs:89 Ok(Writer::from_writer(try!(fs::File::create(path))))

^~~~~~~~~~~~~~~~

<std macros>:1:1: 6:57 note: in expansion of try!

/home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.13.2/src/writer.rs:89:32: 89:61 note: expansion site

error: aborting due to 2 previous errors

Could not compile `csv`.

Can't decode plain enum

Minimal test case:

extern crate rustc_serialize;
extern crate csv;

#[derive(Debug, RustcDecodable)]
enum Code {
    One, Two, Three
}

fn main() {
    let mut rdr = csv::Reader::from_string("
a,b
One,1
Two,2
Three,3
Two,2
One,1");
    for x in rdr.decode() {
        let x: (Code, i32) = x.unwrap();
        println!("{:?}", x);
    }
}

Output:

thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Decode("Failed converting \'One\' from str.")', ../src/libcore/result.rs:688

Expected output:

(One, 1)
(Two, 2)
(Three, 3)
(Two, 2)
(One, 1)

rustc version: rustc 1.7.0 (a5d1e7a59 2016-02-29)

csv: 0.14.4
rustc-serialize: 0.3.18

Leading spaces in header fields

I came across a CSV file which had leading spaces in the header fields:

medallion, hack_license, vendor_id, pickup_datetime, payment_type, fare_amount, surcharge, mta_tax, tip_amount, tolls_amount, total_amount

When I deserialized it with Serde, each field has a space in front. Would it make sense to have an option to trim the header fields or to transform them in a more general way?

"wrong array length" when two arrays are next to each other

The following panics with thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: Decode("wrong array length")'. I believe that it should work.

extern crate csv;

fn main() {
    let data = "7,7,8,8";
    let mut rdr = csv::Reader::from_string(data).has_headers(false);
    for row in rdr.decode() {
        let (a1, a2): ([u32; 2], [u32; 2]) = row.unwrap();
        println!("{:?} {:?}", a1, a2);
    }
}

Benchmark?

I see some code there for benchmarking against go -- what are the results?

Expected a record with length at least 7, but got a record with length 6.

Trying to parse [https://data.texas.gov/download/r4v4-vz24/application/zip](this GTFS data) with [https://github.com/ndarilek/gtfs-rs](this GTFS parser) I'm building. Unfortunately, I'm running into an issue with optional data. In particular, [https://github.com/ndarilek/gtfs-rs/blob/master/examples/stats.rs](this example) fails on the above dataset (put it in examples/data/gtfs.zip) because the first line of agency.txt has 6 fields, not 7. Even so, many of these fields are optional, and I'd like to represent them with Option instead of as something that may or may not be empty.

Fairly new to Rust. Not sure what the best way to achieve this in a typesafe way is. Since my file has headers, and indeed the headers are required by the GTFS spec, it might be nice if I could import into an associative array keyed off of those headers, since I don't know what kind of data transit agencies might provide. If I convert some of the types in the decode tuple to Option, the expected record length seems to grow (I.e. it expects 8-9 fields, not 7.)

Any help appreciated. Thanks.

Custom Struct Encoding/Decoding

Firstly, I am not sure whether this issue/question belongs here or over at rust-lang/rustc-serialize, but I think I should ask this here first.

I was wondering how one goes about telling CSV and/or serialize that a particular Struct is formatted a particular way. This is probably best illustrated with the following example:

#![feature(phase)]

extern crate csv;
extern crate regex;
#[phase(plugin)] extern crate regex_macros;
extern crate "rustc-serialize" as rustc_serialize;

use std::fmt;
use std::str;

#[deriving(RustcDecodable)]
struct Rational {
    numerator: i64,
    denominator: i64
}

impl fmt::Show for Rational {
    /// Display the rational number as `numerator/denominator`.
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}/{}", self.numerator, self.denominator)
    }
}

impl str::FromStr for Rational {
    /// Parse a string into a Rational.  Allow for the possibility of whitespace around `/`.
    fn from_str(s: &str) -> Option<Rational> {
        if let Some(caps) = regex!(r"^([0-9]+)\s*/\s*([0-9]+)$").captures(s) {
            Some(Rational {
                numerator: caps.at(1).unwrap().parse().unwrap(),
                denominator: caps.at(2).unwrap().parse().unwrap()
            })
        } else {
            None
        }
    }
}

fn main() {
    let data = "
X,Y,Rational
1.1,2.3,5/8
13.21,34.55,144/233
377.610,987.1597,2584/4181";

    let mut rdr = csv::Reader::from_string(data).has_headers(true);
    for row in rdr.decode() {
        let (x, y, r): (f64, f64, Rational) = row.unwrap();
        println!("({}, {}): {}", x, y, r);
    }
}

This will compile fine, but it unsurprisingly results in the error

     Running `target/csv-test`
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: CSV decode error: Struct 'Rational' has 2 fields but current record has 1 fields.', /build/rust-git/src/rust/src/libcore/result.rs:746

since it it expect two columns for Rational.

I have tried to replace the #[deriving(RustcDecodable)] by implementing that trait manually; but I do not seem to be getting very far. This is my attempt so far

impl rustc_serialize::serialize::Decodable<csv::Decoded, csv::Error> for Rational {
    fn decode(d: &mut csv::Decoded) -> Result<Rational, csv::Error> {
        if let Ok(s) = d.read_str() {
            if let Some(r) = s.as_slice().parse::<Rational>() {
                Ok(r)
            } else {
                Err("Unable to parse the string into rational number.")
            }
        } else {
            Err("Unable to read the string.")
        }
    }
}

but for some reason, it seems that read_str is not implemented for csv::Decoded yet the documentation (and source) clearly show that it should be implemented. (It is getting late, so I am perhaps missing something obvious).

Curiously, why does CSV use the serialize crate in order to parse the data? Why not simply use FromStr? It would seem to me a lot more straightforward; especially since as far as I see it, the whole serialize crate is acting like a big and overly complicated wrapper for just FromStr in this context.

Serializing arrays with headers returns error

This is using serde on the rewrite branch.

Creating struct with an array in it causes csv::Writer::serialize to return an UnequalLengths error. Disabling headers prevents the error from occuring.

#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate csv;

#[derive(Serialize)]
struct Foo {
    datas: [String; 2],
}

fn main() {
    let mut writer = csv::WriterBuilder::new().from_path("test.csv").unwrap();
    let data = Foo {
        datas: ["Hello".into(), "world".into()],
    };
    writer.serialize(data).unwrap();
}
 $ env RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/rust-csv-example`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UnequalLengths { pos: None, expected_len: 1, len: 2 }', /checkout/src/libcore/result.rs:859
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:371
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:511
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:495
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:471
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:69
   9: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:29
  10: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/result.rs:737
  11: rust_csv_example::main
             at ./src/main.rs:17
  12: std::panicking::try::do_call
             at /checkout/src/libstd/panicking.rs:454
  13: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  14: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:433
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:57
  15: main
  16: __libc_start_main
  17: _start

Support for string delimiter?

For example, I have some data with below format:

let data = "
sticker||mortals||7
bribed||personae||7
wobbling||poncing||4
interposed||emmett||9
chocolate||refile||7";

Everything is same as normal CSV data except the delimiter is || not ,

Tutorial example tutorial-read-serde-04.rs won't compile

While working through the CSV tutorial at: http://blog.burntsushi.net/csv/
I get a compilation error trying to compile the "tutorial-read-serde-04.rs" example.

error: unknown crate type: proc-macro

I get the error on both rust nightly and rust stable.

PS C:\users\ron\projects\csvtutor> rustup show
Default host: x86_64-pc-windows-msvc

installed toolchains
--------------------

stable-x86_64-pc-windows-msvc (default)
nightly-x86_64-pc-windows-msvc

active toolchain
----------------

stable-x86_64-pc-windows-msvc (default)
rustc 1.17.0 (56124baa9 2017-04-24)

PS C:\users\ron\projects\csvtutor> cargo build --verbose
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name _ --print=file-names --crate-type bin --crate-type proc-macro
--crate-type rlib --target x86_64-pc-windows-msvc` (exit code: 101)
--- stderr
error: unknown crate type: `proc-macro`


PS C:\users\ron\projects\csvtutor>

Here's a copy of my Cargo.toml file:

[package]
name = "csvtutor"
version = "0.1.0"
authors = ["Ron Tilby <[email protected]>"]

[dependencies]
csv = "1.0.0-beta.1"
serde = "1"
serde_derive = "1"

Optional Fields

So I was attempting to use rust-csv to directly read in GTFS data, which is a bunch of csv files with headers. The CSV files may optionally have some fields however, and when they are there I should read them, when they are not, I should be able to skip them.

I didn't see any way to do that with rust-csv with rustc_serialize as it stands today, it looks like I'll have to do some sort of csv -> hashmap -> struct type mapping function. It would be cool if this csv library could deal with optional fields automatically.

Is it possible to skip (n) first lines of the CSV?

At our API it's possbile to upload CSVs. Some of them are generated / exported via excel. That files could contain some "header/encoding-trash" in the first rows. So is it possible to skip n-first-lines, like with the .has_headers option?

Thanks in advance.

Writer: Implement a way to obtain the inner writer

I'm using a csv::Writer<flate2::GzEncoder<File>>, and I'm having issues with writes not being synced to disk properly. I suspect I need to call File::sync_all(). However, AFAIK there is currently no way to access the inner Write object W from a csv::Writer<W>.

Proposal: implement a method on Writer similar to BufWriter's into_inner or GzEncoder's finish(). Something like:

fn into_inner (self) -> Result<W> {
    self.buf.into_inner()
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.