rocksky/decoders
Reusable gleam/dynamic/decode decoders for the public types in
rocksky/types. These are exposed so callers can also decode raw
Dynamic payloads themselves (e.g. embedded in custom responses).
Values
pub fn album() -> decode.Decoder(types.Album)
pub fn api_key() -> decode.Decoder(types.ApiKey)
pub fn artist() -> decode.Decoder(types.Artist)
pub fn list_in_field(
key: String,
inner: decode.Decoder(a),
) -> decode.Decoder(List(a))
Convenience: decode an object whose key field is a list of inner.
pub fn listener() -> decode.Decoder(types.Listener)
pub fn profile() -> decode.Decoder(types.Profile)
pub fn scrobble() -> decode.Decoder(types.Scrobble)
pub fn shout() -> decode.Decoder(types.Shout)
pub fn song() -> decode.Decoder(types.Song)
pub fn stats() -> decode.Decoder(types.Stats)
pub fn unwrap(
field_name: String,
inner: decode.Decoder(a),
) -> decode.Decoder(List(a))
Decode { items: [...] }-shaped responses into a list of items.
Many Rocksky list endpoints wrap their array in a single object field
(e.g. { "scrobbles": [...] }, { "songs": [...] }). This helper hides
that detail from callers that just want the list.