BurntSushi / BurntSushi/rust-csv
Question about deserializing with `serde::de::DeserializeSeed`
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
What I'm trying to do is deserialize a `StringRecord` but ignore some columns. The columns aren't known at compile time.
It's easy to find their positions and grab the cells with `StringRecord::get` but this doesn't make use of the deserializer so I have to infer/guess the type myself. Which really isn't all that bad really, but it might be favourable to use the serde infrastructure.
In my scenario, the columns I'm interested in deserializing is only known at run time. I can't figure out how to get this to work in the current API this crate provides. Here's the two things I've tried.
1. I could use `DeserializeSeed` to deserialize a row using a stateful object that knows what what cells to skip over and which to deserialize. However, this takes a `Deserializer` and this library doesn't appear to offer that in the API.
2. Since I know what cells I need, I could also use a form of `StringRecord::get` that also takes a type parameter that implements `Deserialize` and deserializes the cell to that type. Sort of like `StringRecord::deserialize` but for just the cell instead of the entire row.
Is there any way to accomplish what I'm trying to do using the current API that I've missed?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.