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).
Types
pub type Album =
types.AlbumViewBasic
pub type Artist =
types.ArtistViewBasic
pub type Listener =
types.SongRecentListenerView
pub type Profile =
types.ActorProfileViewBasic
pub type Scrobble =
types.ScrobbleViewBasic
pub type Song =
types.SongViewBasic
pub type Stats =
types.StatsView
Values
pub fn album() -> decode.Decoder(types.AlbumViewBasic)
pub fn api_key() -> decode.Decoder(types.ApiKey)
pub fn artist() -> decode.Decoder(types.ArtistViewBasic)
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.SongRecentListenerView)
pub fn profile() -> decode.Decoder(types.ActorProfileViewBasic)
pub fn scrobble() -> decode.Decoder(types.ScrobbleViewBasic)
pub fn shout() -> decode.Decoder(types.Shout)
pub fn song() -> decode.Decoder(types.SongViewBasic)
pub fn stats() -> decode.Decoder(types.StatsView)
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.