[][src]Module xnde::tracks

Track type


This module introduces the Track struct, which represents a single track in your Winamp Music Library. The idea is to map each record in the NDE "main" table to a Track instance. Track derives the Serialize Serde trait, making it easy to write to file.


This is probably the module with which I am the least satisfied. The design problem is:

  1. the attributes of a track shall be derived at runtime from the columns in the Music Library Database main table rather than fixed at compile time.

  2. even at runtime, within the table, not every column is guaranteed to appear in any given record

I solved this by first building a mapping from column ID to track attributes (when reading the first record of the table). For each subsequent record, that lets me map each field (for which I have a column ID) to the corresponding track attribute. I use a per-record map of TrackAttribute to FieldValue to keep track of what I've seen so far (since I don't want to count even on the fields appearing in the same order). Finally, once I've parsed the entire record, I read the elements out & into the new Track instance.

The basic design isn't awful, but the implementation code is prolix & inelegant. Suggestions welcome.



Winamp Music Library track



Enumerated set of attributes which Track may include



Build a ColumnMap from the columns in a table's first record

Type Definitions


Map NDE table columns (discovered at runtime) to Track attributes (fixed at compile-time)