rocksky/filter
Pipe-friendly builder for RSQL filter expressions, accepted by the
filter parameter of the catalog and scrobble-feed queries
(app.rocksky.song.getSongs, app.rocksky.artist.getArtists,
app.rocksky.album.getAlbums, app.rocksky.scrobble.getScrobbles).
Fields are typed (Field — filter.Artist, filter.Duration,
dotted scrobble selectors like filter.TrackArtist, and a
CustomField("…") escape hatch), and the filter value is always the
first argument of the combinators, so expressions chain with |>:
filter.eq(filter.Artist, “Daft Punk”) |> filter.and(filter.gt(filter.Duration, 200_000)) |> filter.or(filter.in_list(filter.Genre, [“house”, “electro”])) |> filter.build // artist==“Daft Punk”;duration=gt=200000,genre=in=(house,electro)
String values are quoted and escaped automatically when they contain
characters RSQL reserves; * wildcards pass through unquoted so
filter.eq(filter.Artist, "Daft*") performs a case-insensitive match.
Types
A filterable field — the union of the known fields of the four
RSQL-filterable queries (songs, artists, albums, scrobbles). The dotted
Track* / User* / Artist* variants are the scrobble feed’s joined
selectors. Any selector not covered here can be reached with
CustomField.
pub type Field {
Title
Artist
Album
AlbumArtist
Genre
Genres
Composer
Label
Duration
TrackNumber
DiscNumber
MbId
Isrc
Sha256
Uri
AlbumUri
ArtistUri
CreatedAt
Name
BornIn
Born
Died
Year
ReleaseDate
Date
Timestamp
TrackTitle
TrackArtist
TrackAlbum
TrackAlbumArtist
TrackGenre
TrackDuration
TrackIsrc
TrackMbId
UserDid
UserHandle
UserDisplayName
ArtistName
ArtistGenres
CustomField(String)
}
Constructors
-
Titletitle -
Artistartist -
Albumalbum -
AlbumArtistalbumArtist -
Genregenre -
Genresgenres(artists) -
Composercomposer -
Labellabel -
Durationduration -
TrackNumbertrackNumber -
DiscNumberdiscNumber -
MbIdmbId -
Isrcisrc -
Sha256sha256 -
Uriuri -
AlbumUrialbumUri -
ArtistUriartistUri -
CreatedAtcreatedAt -
Namename(artists) -
BornInbornIn(artists) -
Bornborn(artists) -
Dieddied(artists) -
Yearyear(albums) -
ReleaseDatereleaseDate(albums) -
Datedate(scrobbles) -
Timestamptimestamp(scrobbles) -
TrackTitletrack.title(scrobbles) -
TrackArtisttrack.artist(scrobbles) -
TrackAlbumtrack.album(scrobbles) -
TrackAlbumArtisttrack.albumArtist(scrobbles) -
TrackGenretrack.genre(scrobbles) -
TrackDurationtrack.duration(scrobbles) -
TrackIsrctrack.isrc(scrobbles) -
TrackMbIdtrack.mbId(scrobbles) -
UserDiduser.did(scrobbles) -
UserHandleuser.handle(scrobbles) -
UserDisplayNameuser.displayName(scrobbles) -
ArtistNameartist.name(scrobbles) -
ArtistGenresartist.genres(scrobbles) -
CustomField(String)Escape hatch: any selector not covered above, passed through verbatim.
Values
pub fn and(a: Filter, b: Filter) -> Filter
Both sides must match (;). An or operand is parenthesized to keep
RSQL precedence: a |> filter.and(b).
pub fn build(f: Filter) -> String
The RSQL expression string to send as the filter query param.
pub fn eq(field: Field, value: String) -> Filter
field==value — equals; * in the value is a wildcard.
pub fn eq_bool(field: Field, value: Bool) -> Filter
field==true / field==false — equals, boolean value.
pub fn in_list(field: Field, values: List(String)) -> Filter
field=in=(a,b) — matches any of the values.
Panics when values is empty — an RSQL in needs at least one value.
pub fn ne_bool(field: Field, value: Bool) -> Filter
field!=true / field!=false — not equals, boolean value.