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§
- Edit
Result - The result of
apply_edits. - Edit
Warning - 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-orderwarning that changes one or two digits (R13.7). - Time
Value - The time of a line (R13.2.5).
- Tracklist
- The result of
parse_tracklist: one entry per line, the warnings and the counts. - Tracklist
Entry - One line of a tracklist.
- Tracklist
Options - Options of
parse_tracklist_with(R13.10). - Tracklist
Warning - 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.
- Edit
Warning Code - The code of an edit warning (R13.9).
- Entry
Kind - What a line of a tracklist is (R13.3).
- Eol
- The line terminator that followed a line (R13.1.1);
Nonewhen the text ended without one. - Severity
- How serious a tracklist warning is.
- Warning
Code - 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_editswith 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_tracklistwith options (R13.10).