Skip to content

Add RelationshipHookMode argument to BundleWriter::write#24406

Open
eugineerd wants to merge 1 commit into
bevyengine:mainfrom
eugineerd:bundle-writer-relationship-hook
Open

Add RelationshipHookMode argument to BundleWriter::write#24406
eugineerd wants to merge 1 commit into
bevyengine:mainfrom
eugineerd:bundle-writer-relationship-hook

Conversation

@eugineerd
Copy link
Copy Markdown
Contributor

@eugineerd eugineerd commented May 23, 2026

Objective

I've been using BundleScratch for batch writing components when synchronizing entities across worlds, it's been quite nice. However currently BundleWriter::write doesn't allow setting RelationshipHookMode, which makes it less usable for this task since it requires mapping entities when inserting relationships while also preserving ordering in RelationshipTargets (which becomes broken when running with the default RelationshipHookMode::Run)

Also BundleWriter::write was missing #[track_caller].

Solution

  • Add RelationshipHookMode argument to BundleWriter::write and set all existing calls to use RelationshipHookMode::Run, which was the default passed by it when inserting components.
  • Annotate BundleWriter::write with #[track_caller]

Testing

  • The one existing test that used BundleWriter::write passed

@kfc35 kfc35 added A-ECS Entities, components, systems, and events D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 23, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in ECS May 23, 2026
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

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

Not knowledgable enough to know whether the api change is worth it / if most cases should just use RelationshipHookMode::Run and not think too much about it, but the logic looks good to me

Comment thread crates/bevy_ecs/src/bundle/writer.rs
@kfc35 kfc35 added this to the 0.19 milestone May 24, 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 D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

2 participants