-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Serde #172
Conversation
close #165 |
Latest update worked for me, swapped out all the xml-rs for quick-xml and everything working properly. |
Not sure your opinion on this, but for http://gd2.mlb.com/components/game/mlb/year_2008/month_02/day_26/gid_2008_02_26_fanbbc_phimlb_1/players.xml I'm using this struct: struct Team {
#[serde(rename="type")]
home_away: HomeAway,
id: String,
name: String,
#[serde(rename="player")]
players: Vec<Player>,
#[serde(rename="coach")]
coaches: Vec<Coach>,
} This returns an Error (missing field 'coach'), since one of the teams doesn't have any coaches in the file. Would it be better (or even possible?) to return an empty vec, rather than having to wrap the field in an option. |
Have you tried adding a #[serde(rename="coach", default)]
coaches: Vec<Coach>, |
Always something to learn with SerDe! Yes, that is definitely the better way to do it. QuickXML with SerDe has been working flawlessly on a pretty large sample size. |
Thank you for the feedbacks, it helps a lot! |
- disable default `serialize` feature (must opt-in now) - add documentation for `crate::de` module
Add a
serialize
feature to allow (de)serializing xmls.This is hugely inspired by serde-xml so most of the credit goes to them.
For the moment only Deserialization has been worked on. Serialization should be simpler.
In terms of performance, there is probably some optimization to do in the future. In particular we should be able to avoid the
'static
lifetime inDeserializer::next
(thus avoiding some unecessary allocations/copy).