Please don’t rely on this Gitea instance being around forever. If any of your build scripts use my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking for there, tell me to migrate it.
A serde parser for MPD responses. Includes mpd structs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kageru 46dc0ac622
Update readme
2 years ago
src Add serialize derive to all structs 2 years ago
.gitignore initial commit 3 years ago
Cargo.lock Add crates.io to readme 2 years ago
Cargo.toml Release 0.2.0 2 years ago
LICENSE Update readme 2 years ago
README.md Update readme 2 years ago
rustfmt.toml Remove unstable options from rustfmt.toml 2 years ago

README.md

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

mparsed

A serde parser for MPD responses. Includes mpd structs.

This project is on crates.io.

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:

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.

Now you can simply:

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.

Oh, and its a good learning opportunity for me. Serde seemed like a library I should learn more about.

Youre 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.