bevyengine / bevyengine/bevy

`Image` fields should not be public

Open
#11,888 1 comment 3 reactions 0 assignees View on GitHub
A-Rendering C-Code-Quality C-Usability D-Modest S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

The `Image` type has quite a few complex invariants to uphold, around data layout and byte intepretation.

As a result, it has several nice constructors, which do the math for you.

However, the fields are fully public, and can be constructed in or modified to be invalid with no protections.

## What solution would you like?

All fields should be private, and getters and setters should be added, which should generally return error types.

## What alternative(s) have you considered?

Leave it alone: maybe the rendering people have good reasons to do cursed transmute-style type punning?

## Additional context

We might also want to add non-panicking variants to the various panicking methods at the same time.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.