Skip to content

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

Open
@dvdsk

Description

@dvdsk

Idea by @The0x539 #626 (comment). 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions