Skip to main content

Module tracklist

Module tracklist 

Source
Expand description

Multi-line tracklists (SPEC R13): parse_tracklist and apply_edits.

A tracklist is the text people paste under a mix: one track per line, usually with a cue time, sometimes with headers, links and notes in between. parse_tracklist gives one TracklistEntry per line and never changes or drops a line; apply_edits rewrites the text (set a time, shift, sort, insert, delete) and leaves every other byte alone.

Guides: https://4matic.github.io/trackparse/guides/tracklists/ and https://4matic.github.io/trackparse/guides/editing-tracklists/.

use trackparse::tracklist::{parse_tracklist, EntryKind};

let list = parse_tracklist("Tracklist:\n\n00:00 Intro\n01:30 Noisia - Stigma\n");
let kinds: Vec<EntryKind> = list.entries.iter().map(|e| e.kind).collect();
assert_eq!(kinds, [EntryKind::Header, EntryKind::Blank, EntryKind::Marker, EntryKind::Track]);
assert_eq!(list.stats.timed, 2);
assert!(list.warnings.is_empty());

Rule IDs (R13.2…) refer to the spec. The output is byte-identical to trackparse/tracklist in the JavaScript package and trackparse.tracklist in Python.

Structs§

EditResult
The result of apply_edits.
EditWarning
A warning about one edit.
Parts
A line cut into four pieces that join back to it: lead + time + gap + rest == raw (R13.1.3).
Stats
Counts over a tracklist.
Suggestion
A fix for a time-out-of-order warning that changes one or two digits (R13.7).
TimeValue
The time of a line (R13.2.5).
Tracklist
The result of parse_tracklist: one entry per line, the warnings and the counts.
TracklistEntry
One line of a tracklist.
TracklistOptions
Options of parse_tracklist_with (R13.10).
TracklistWarning
A warning about a tracklist (R13.7).

Enums§

Edit
One edit of a tracklist text (R13.9). Line numbers are 1-based and refer to the text as the previous edit left it.
EditWarningCode
The code of an edit warning (R13.9).
EntryKind
What a line of a tracklist is (R13.3).
Eol
The line terminator that followed a line (R13.1.1); None when the text ended without one.
Severity
How serious a tracklist warning is.
WarningCode
The code of a tracklist warning (R13.7), in the table order of the spec.

Functions§

apply_edits
Apply edits to a tracklist text (R13.9), in order, each to the result of the previous one.
apply_edits_with
apply_edits with options. The options are accepted for symmetry with the other ports (R13.10); edits do not depend on them today.
parse_tracklist
Parse a multi-line tracklist with the default options (R13).
parse_tracklist_with
parse_tracklist with options (R13.10).