loyd / rscam

Rust wrapper for v4l2
Other
116 stars 22 forks source link

Iterator<Item=(u32, u32)> for Discrete/Stepwise enums (`ResolutionInfo` and `IntervalInfo`) #12

Open Boscop opened 6 years ago

Boscop commented 6 years ago

Re: https://github.com/loyd/rscam/issues/10

In the example Stepwise variant represents { ∀k≥0,m≥0 | (min(320 + kstep.0, 640), min(240 + mstep.1, 360)) }

It would be useful to have an iterator over this, for all enums with Discrete/Stepwise, i.e. ResolutionInfo and IntervalInfo.

E.g. it could be done by merging both types into one, as they are basically the same, and then making both an alias for that type. And then implementing Iterator<Item=(u32, u32)> for this type.

Having an iterator would make it easier to find the best setting to choose, as they can be zipped and mapped with a custom weighing function between fps and resolution, and then find the .max() :)