I'm trying to make a deserializer for the FullOrder struct from the CEX.IO exchange (https://cex.io/rest-api#/definitions/FullOrder). It unfortunately doesn't contain a consistent definition, and has fields as labelled below:
ta:{symbol2} string total amount in current currency (Maker)
tta:{symbol2} string total amount in current currency (Taker)
fa:{symbol2} string fee amount in current currency (Maker)
tfa:{symbol2} string fee amount in current currency (Taker)
a:{symbol1}:cds string credit, debit and saldo merged amount in current currency
So, for example, it could be tta:USD
in one message or tta:EUR
in another.
I've been following this guide (https://serde.rs/deserialize-struct.html) in creating my struct, and I've got all the way through it bar one thing - the final part requires specifying all the fields.
In the field visitor, I have the following to handle the fields in advance:
if value.starts_with("ta:") {
Ok(Field::TotalMakerAmount)
} else if value.starts_with("tta:") {
Ok(Field::TotalTakerAmount)
} else if value.starts_with("fa:") {
Ok(Field::FeeMakerAmount)
} else if value.starts_with("tfa:") {
Ok(Field::FeeTakerAmount)
} else if value.starts_with("a:") {
Ok(Field::CreditDebitSalvo)
But the deserialize_struct requires a list of all the fields to visit. Is there anyway I can get a hold of all fields dynamically to pass through here? Or have I reached the extreme of what a serde deserializer can do?
Thanks