mparsed/README.md

39 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2020-06-13 09:23:09 +02:00
# mparsed
2020-06-21 23:28:45 +02:00
A serde parser for MPD responses. Includes mpd structs.
2020-07-24 15:10:25 +02:00
This project is on [crates.io](https://crates.io/crates/mparsed).
2020-06-21 23:28:45 +02:00
## Why?
Because there are lots of mpd client libraries for Rust,
but most (maybe all?) of them write the same awful deserialization code
that more or less looks like this:
```rs
let mut track = Track::default();
match key {
"title" => track.title = value,
"artist" => track.artist = value,
"album" => track.album = value,
...
```
And I figured just having a small crate that has all the types and does the serde magic for you would be nice for other people as well.
2020-07-24 18:34:39 +02:00
Now you can simply:
```rs
let raw_response: Vec<String> = my_mpd_client.currentsong(); // <- this one is from your own code
let track: Track = mparsed::deserialize_response(raw_response.iter());
```
No more hand-written deserialization logic.
2020-06-21 23:28:45 +02:00
Oh, and it’s a good learning opportunity for me.
Serde seemed like a library I should learn more about.
### You’re missing `MyFavoriteStruct`!
Feel free to submit a PR for it.
This is still very much work in progress,
but I think we should have most necessary helper functions so that you can just write the struct definition with some serde attributes and be done with it.