Struct Timeline

Source
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

Source

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.

Source

pub fn cues(&self) -> &[Cue]

The distinct cues in increasing timestamp order.

Source

pub fn is_empty(&self) -> bool

Whether the lyrics have no timed cue.

Source

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.

Trait Implementations§

Source§

impl Clone for Timeline

Source§

fn clone(&self) -> Timeline

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Timeline

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Timeline

Source§

fn default() -> Timeline

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Timeline

Source§

fn eq(&self, other: &Timeline) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Timeline

Source§

impl StructuralPartialEq for Timeline

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,