Skip to content

Recording has no duration(), so the length of a recording is frames().last() arithmetic #307

Description

@vyncint

TodayRecording exposes frames(), len(), is_empty(), dropped(), to_asciicast() and write_asciicast(). Measured on 0.10.1 (grep 'pub fn' inside impl Recording): there is no duration(), so a test asking how long an animation took writes

let took = recording.frames().last().map(|(at, _)| *at).unwrap_or_default();

Why it is worth fixing — "did this redraw finish within X?" is one of the two questions a recording is for (the other is the frame sequence itself), and len() already exists for the other one. The asciicast header has a duration field this would also feed (see #309).

Fix — add Recording::duration(&self) -> Duration in crates/termlens/src/terminal.rs, returning the timestamp of the last frame (zero when empty). Its rustdoc should say what the span is measured between — the recorder starting and the last complete frame — since that is not the same as the process's lifetime.

Done when

  • duration() exists, documented, returning zero for an empty recording.
  • A case in crates/termlens/tests/record.rs asserts it is monotonic with the last frame's timestamp.

A good first contribution: one file, no architecture decisions. Start with
CONTRIBUTING.md
— §1 lists every gate you can run locally, and §3 asks that a change land
with a test. Commits are Conventional Commits and need git commit -s
(DCO). Happy to review a draft PR early.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions