mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[GH-ISSUE #149] The way to reduce wrapper object. #52
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#52
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ramsayleung on GitHub (Nov 7, 2020).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/149
There are several wrapper objects in the model module, which tried to deserialize endpoint response to a decent struct.
For example, the response of
albumsendpoint is something like this:instead of a pure JSON array containing a list of
FullAlbumobject:Thus, in order to deserialize the
Vec<FullAlbum>from HTTP response, I built a wrapper struct namedFullTracksto handle this deserialization :Yes, it works well, but makes the API more verbose to use, you have to introduce more additional structs into your application, and the wrapper objects actually are some temporary object, so it's time to reduce this wrapper object, to make it more easier to use.
After investigating into the
serdecrate for a while, it seems there is no built-in way to strip the outeralbumsfield out. Then another solution comes to my mind that we keep the wrapper object, but inside the function scope, makes it no need to export to developers:I'd like to tag @Koxiaet again, who opened an issue #127 with a very opinionated list of improvements and mentioned the benefit and necessity to reduce these wrapper object; I'm sure they can help with this as well :)
@Kestrer commented on GitHub (Nov 7, 2020):
This sounds like a good idea! Thanks so much for all the improvements to rspotify :)
position_mstostart_playback#212