pub struct Timeline { /* private fields */ }Expand description
A chronological index of a track’s synchronized lyrics.
Preparation takes O(n log n) time and O(n) auxiliary storage for n lyric lines, without cloning their text. Each position lookup takes O(log c) time for c distinct cues. There is no clock or moving cursor: a caller can pause, seek backward or repeat by supplying its current track position.
Untimed lines remain in Lyrics for plain-text display, but are excluded
here: the index never invents a timing for metadata or unmarked verses.
Timed blank lines are retained because they stop the previous text.
Implementations§
Source§impl Timeline
impl Timeline
Sourcepub fn new(lyrics: &Lyrics) -> Self
pub fn new(lyrics: &Lyrics) -> Self
Indexes all timed lines without changing their source order or content.
Input timestamps may be unsorted. Chronological order is deterministic,
with original line order breaking ties. The index owns only timestamps
and indices, so the caller keeps the unmodified Lyrics alongside it.
Memory grows linearly with the supplied lines; this constructor does
not impose another size limit on publicly constructed lyrics.
Sourcepub fn active_at(&self, position_ms: u64) -> Option<&Cue>
pub fn active_at(&self, position_ms: u64) -> Option<&Cue>
Finds the most recent cue at or before a decoded-track position.
The timestamp is inclusive. Before the first cue, or with plain lyrics,
this returns None. The last cue remains active until the caller ends
the track; no lyric duration is guessed from its text. An active blank
cue is returned rather than skipped, allowing the client to clear text.