You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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?
The text was updated successfully, but these errors were encountered:
sqwishy
changed the title
Question about deserializing with serde::de::DeserializeSeed
Question about deserializing with serde::de::DeserializeSeedDec 29, 2021
I don't believe there is any way to do what you want with the current API, and I think making it possible would be a fair bit of work and an addition of a decent bit of complexity.
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.
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 aDeserializer
and this library doesn't appear to offer that in the API.Since I know what cells I need, I could also use a form of
StringRecord::get
that also takes a type parameter that implementsDeserialize
and deserializes the cell to that type. Sort of likeStringRecord::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?
The text was updated successfully, but these errors were encountered: