License Crates.io Docs.rs

serde-csv-extra

Csv-related serde addons

```rust use serde::{Deserialize, Serialize};

[derive(Deserialize, Serialize)]

struct Foo { #[serde(with = "serdecsvextra::vecnum")] list: Vec, #[serde(with = "serdecsvextra::vecvecnum")] matrix: Vec>, #[serde(with = "serdecsvextra::maybeimagesize")] imagesize: Option<(u8, u16)>, #[serde(with = "serdecsvextra::maybelatlon")] geo: Option<(f32, f32)>, }

let mut wtr = csv::WriterBuilder::new().hasheaders(false).fromwriter(Vec::new()); wtr.serialize( Foo { list: vec![-1, 1], matrix: vec![vec![-1, 1], vec![1, -1]], imagesize: Some((16, 1024)), geo: Some((84.99, -135.00)), } ).unwrap(); wtr.serialize( Foo { list: vec![], matrix: vec![], imagesize: None, geo: None, } ).unwrap(); let s = String::fromutf8(wtr.intoinner().unwrap()).unwrap(); asserteq!(s, "-11,-11|1-1,16x1024,84.99;-135\n,,,\n"); ```

Contributing

We appreciate all kinds of contributions, thank you!

Note on README

The README.md file isn't meant to be changed directly. It instead generated from the crate's docs by the [cargo-readme] command:

If you have [rusty-hook] installed the changes will apply automatically on commit.

License

This project is licensed under the MIT license.