Module query

Source
Expand description

A query language over the catalog and over what the user wrote about it.

Options compose by AND and by nothing else. That is the ceiling no number of new flags ever raises: there is no --genre metal OR --genre jazz, no “everything except this label”, no “between 1990 and 1999”. A grammar has all three for free, and having one is what turns a saved query into a smart collection — which, since a selection is already what --csv, --m3u and M3’s queue consume, is playable the day it is written.

genre:metal year:1990..1999 rating:>=4 -label:earache
(artist:ozzy OR artist:dio) loved
album.rating:5 played:0
work:"War Pigs" instrument:guitar
guest:"Zakk Wylde" with:"Ozzy Osbourne"

It is an interface, not a storage engine. Defined on its own it works today over the vectors in memory and tomorrow over SQL. Defined as “whatever the database makes easy” it would arrive late and shaped by the wrong concerns.

Everything evaluates against a track, because a track is the finest grain and every coarser answer is a fold of it: the albums matching a query are the albums of the tracks matching it. One evaluator, not five.

Modules§

browse
Versioned dynamic browsing collections; audio and catalog identities remain unchanged.

Structs§

Context
Everything needed to answer, gathered once rather than per track.
QueryError
Why a query could not be read.
Sort
How a result is ordered.
Term
One condition: a field, and what it is being asked.

Enums§

Compare
How two numbers are compared.
Field
Which value of a track a term reads.
Query
A parsed query, ready to be run against any catalog.
Scope
Which entity an opinion was written on.
SortKey
What a result can be ordered on.
Test
What a term asks of a value.

Functions§

asks_about_the_track_itself
true when the expression asks about something the user wrote, at the track’s own scope — the case where rescoped has anything to offer.
field_names
The field names, for a help message or a completion.
matches
Whether one track satisfies a query.
parse
Reads a query, rejecting incomplete operators and invalid numeric bounds.
rescoped
The same question, asked of the album or the artist instead of the track.
run
The tracks a query matches, in catalog order.
sort
Puts a result in order.
sort_key_names
The sort keys, for a help message.
unknown_values
Values a query names that the library has never heard of.