Skip to content

Rename and document fields in Access.#24778

Open
andriyDev wants to merge 4 commits into
bevyengine:mainfrom
andriyDev:rename-reads-and-writes
Open

Rename and document fields in Access.#24778
andriyDev wants to merge 4 commits into
bevyengine:mainfrom
andriyDev:rename-reads-and-writes

Conversation

@andriyDev

Copy link
Copy Markdown
Contributor

Objective

  • Fix some confusing naming of Access.

Solution

  • Rename reads_and_writes to just reads, and explain in the doc comment that write access also implies read access.

@andriyDev andriyDev added C-Docs An addition or correction to our documentation D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 27, 2026
@andriyDev andriyDev requested a review from chescock June 27, 2026 19:47
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in ECS Jun 27, 2026

@Zeophlite Zeophlite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirmed this is just renames

@chescock chescock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! I think it needs a migration guide before merging, though.

Did we want to consider renaming add_write to add_read_and_write and remove_read to remove_read_and_write? That could also help for clarity, since add_write() now affects the value returned by try_reads(). But it's also a lot more verbose.

/// Returns the set of components with read or write access,
/// Returns the set of components with read access,
/// or an error if the access is unbounded.
pub fn try_reads_and_writes(&self) -> Result<&ComponentIdSet, UnboundedAccessError> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need a migration guide for this, and it might be good to leave the old name as #[deprecated] for a release.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread crates/bevy_ecs/src/query/access.rs Outdated
/// present in `Self::read_and_writes`.
read_and_writes_inverted: bool,
/// present in [`Self::reads`].
read_inverted: bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is pluralized in writes_inverted, so we should probably be consistent. But if we're going to replace it with an enum soon then it doesn't really matter!

Suggested change
read_inverted: bool,
reads_inverted: bool,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

@kfc35 kfc35 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

@andriyDev andriyDev left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@chescock Personally, I don't think we need the extra verbosity. To me at least, it seems intuitive that write access implies read access - that's exactly how system params work, if I ask for &mut Component I also get read access (and the doc comments also spell this out now).

The one I'm least confident about is remove_read_and_write. I think though just changing the doc comment is sufficient.

Comment thread crates/bevy_ecs/src/query/access.rs Outdated
/// present in `Self::read_and_writes`.
read_and_writes_inverted: bool,
/// present in [`Self::reads`].
read_inverted: bool,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

/// Returns the set of components with read or write access,
/// Returns the set of components with read access,
/// or an error if the access is unbounded.
pub fn try_reads_and_writes(&self) -> Result<&ComponentIdSet, UnboundedAccessError> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@andriyDev andriyDev force-pushed the rename-reads-and-writes branch from 54856c7 to 943c5e1 Compare June 28, 2026 17:05
@andriyDev andriyDev added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change C-Docs An addition or correction to our documentation D-Trivial Nice and easy! A great choice to get started with Bevy M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants