Remove the config iterator types from `DeviceTrait`

Open
#1,434 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start with the DeviceTrait definitions in src/traits.rs at the linked lines, then inspect the host implementations of supported_input_configs() and supported_output_configs() to confirm their iterator return types. Change the API to return vectors and check affected custom host implementations or tests. Done means the trait and implementations agree and the project builds successfully.

Written by the indexing model from the issue text.

Description

API design

https://github.com/RustAudio/cpal/blob/44ba7ad0c413d10de12f179091423a569a73395c/src/traits.rs#L129-L133

I suggest removing these in favor of just returning a Vec<T> from supported_in/output_configs(), since they are cumbersome to work with, and config enumeration is a fairly cold path. But more importantly:

Every single host already uses std::vec::Iter<T> here anyway 😅

This may break custom hosts, but the fix is as simple as calling .collect()

Dominant language
Rust
Stars
4k
Forks
554
Avg merge
1d 3h
Merged PRs (30d)
1

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/cpal

All issues in RustAudio/cpal

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.