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

OutputInfo::line_size should be a method #521

Open
Shnatsel opened this issue Oct 5, 2024 · 2 comments
Open

OutputInfo::line_size should be a method #521

Shnatsel opened this issue Oct 5, 2024 · 2 comments

Comments

@Shnatsel
Copy link
Contributor

Shnatsel commented Oct 5, 2024

As of v0.17.14, the OutputInfo struct has a pub field line_size that seems to be computed entirely from other fields - namely width, height and bit depth.

Since the field is public, it is possible for the API user to mutate it and put the whole OutputInfo in an inconsistent state where the values of the fields end up conflicting each other.

It would be nice to turn one of these fields into a method that computes data from the other values, so that it's no longer possible to create structs with conflicting values.

@Shnatsel
Copy link
Contributor Author

Shnatsel commented Oct 5, 2024

Also, FrameInfo seems to be a better name for it than OutputInfo, and we might want to change it while we're at it.

@fintelia
Copy link
Contributor

fintelia commented Oct 5, 2024

The OutputInfo object is only returned from next_frame so it seems harmless to have all public fields. Though it is a bit awkward that it gets returned at the same time as the frame data, even though you have to pass in a properly sized &mut [u8] to the function in the first place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants