Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to return a vector of all the handles in a queue #16

Merged
merged 5 commits into from
Nov 19, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/tracks/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ impl TrackQueue {

inner.stop_current()
}

/// Returns Vec of all handles in queue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main points to mention in docs after the headline:

  • Reordering the queue can't be done here, and has to go through modify_queue. The returned Vec is a snapshot of the queue at the time of call, and might change afterwards.
  • Calling stop on a handle will effectively skip that track.

Minor nits:

  • can you please end doc comments with a full stop?
  • Maybe something like "Returns a list of currently queued tracks." for the headline?

pub fn to_vec(&self) -> Vec<TrackHandle> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn to_vec(&self) -> Vec<TrackHandle> {
pub fn current_queue(&self) -> Vec<TrackHandle> {

This is a little more descriptive of the function's purpose here.

let inner = self.inner.lock();

inner.tracks.iter().map(|q| q.handle()).collect()
}
}

impl TrackQueueCore {
Expand Down