Idea/proposal: Total_duration enum (unknown/max/guarenteed)

Open
#702 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #863 by @Sim-hu — closed without merging

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust

Research direction

Read the linked proposal in issue #626 and compare it with the existing total_duration behavior described here, including TakeDuration and skippable. The issue proposes a SourceDuration enum and helper methods, with returning Duration::MAX for infinite sources as a simpler alternative; first determine whether either approach is still wanted. Done means the project has chosen and implemented a consistent duration representation for these cases.

Written by the indexing model from the issue text.

Description

enhancement good first issue

Idea by @The0x539 https://github.com/RustAudio/rodio/issues/626#issuecomment-2661094585. Currently infinite sources will return None for total_duration, when paired with a TakeDuration you still get None. Another place we can do better is skippable. Right now a skippable will pass on the total_duration of what it wraps. Because the source can be skipped at any point there is no guarentee it will actually play for that length.

To address these issues we can put extra information in the total_duration result:

enum SourceDuration {
  Max(Duration),
  Guarenteed(Duration),
  Infinite,
  Unknown,
}

We could provide methods to turn this into an option returning Duration::MAX for Infinite. We could call that method known. We could also provide a map, is_known and maybe an unwrap_or.

A far simpler alternative to this proposal would be making infinite sources return Duration::MAX.

Dominant language
Rust
Stars
2.5k
Forks
338
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RustAudio/rodio

All issues in RustAudio/rodio

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.