bevyengine / bevyengine/bevy

Support reflection-based serialization on bundled hash set implementations

Open
#14,612 7 comments 0 reactions 0 assignees View on GitHub
A-Reflection C-Usability D-Modest S-Ready-For-Implementation X-Uncontroversial
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

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

Bevy bundles a few hash map / hash set implementations suitable for games (i.e. performant above all else) publicly in `bevy_utils`. Currently it's a combination of hashbrown (an implementation of the awesome abseil swisstables) and a fast hashing algorithm. However, the hash map does not support reflection serialization (does not implement the relevant traits), which makes it impossible to use with moonshine_save (or any other reflection-based save/load system).

## What solution would you like?

Just implement `Serialize`/`Deserialize` on HashMap *and* HashSet. hashbrown already has the relevant serde implementations, so there is no technical reason why this shouldn't work (hand off to the serde implementation for both serializing and deserializing).

## What alternative(s) have you considered?

Not sure if there is an elegant workaround, the reflection system is so opaque to me that I can't figure out how to implement ReflectSerialize (or any other trait, idk) for HashSet. I'd appreciate one, though.

Contributor guide

Open the contributing guide

Research direction

Start in bevy_utils by locating the bundled HashMap and HashSet implementations, then inspect how hashbrown exposes its serde support. Confirm how the reflection-based save/load path consumes serialization traits. Done means both implementations support Serialize and Deserialize and can be used by reflection-based serialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.