0

For example, I have a string dog 5 true and want to serialize it into a Rust data struct using serde:

struct Pet {
    pub name: String,
    pub age: u32,
    pub alive: bool,
}

Is it possible? If it is, how to accomplish that with Serde custom deserializer?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
bhat
  • 13
  • 5
  • Is that data format required? You might run into issues with determining if a space is continuing a String or separating fields. But on the other hand if you are able to change the formatting, why not use an existing format like CBOR, JSON, or RON? – Locke Oct 25 '19 at 19:29
  • Yeah it's required, and it's probably better to just parse it manually – bhat Oct 25 '19 at 19:32
  • The [duplicate applied to your case](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1fa2d598fead8fab9d8c48fe169e4477) – Shepmaster Oct 25 '19 at 20:16

0 Answers0