Skip to content

Commit

Permalink
feat: added "serde" feature flag for bones_ecs (#438)
Browse files Browse the repository at this point in the history
There were existing of `#[cfg_attr(feature = "serde",
derive(serde::Serialize, serde::Deserialize))]` lines already (f.e. on
Entity struct), but serde feature flag itself was missing from
bones_ecs.

Also added `cfg_attr(feature = "serde") ...` line to Entities and
BitSetVec so Entities struct can be serialized.
  • Loading branch information
defic authored Aug 16, 2024
1 parent 1a16ce9 commit 8fba451
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions framework_crates/bones_ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ keywords.workspace = true
default = ["derive", "keysize16"]
derive = ["dep:bones_ecs_macros"]
glam = ["dep:glam", "dep:paste", "bones_schema/glam"]
serde = ["dep:serde"]

keysize16 = []
keysize20 = []
Expand All @@ -33,6 +34,7 @@ bitset-core = "0.1"
thiserror = "1.0"
glam = { version = "0.24", optional = true }
paste = { version = "1.0", optional = true }
serde = { version = "1", features = ["derive"], optional = true }
once_map = "0.4.12"

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions framework_crates/bones_ecs/src/bitset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub(crate) const BITSET_SLICE_COUNT: usize = BITSET_SIZE / (32 * 8 / 8);

/// The type of bitsets used to track entities in component storages.
/// Mostly used to create caches.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Deref, DerefMut, Clone, Debug)]
pub struct BitSetVec(pub Vec<[u32; 8]>);

Expand Down
1 change: 1 addition & 0 deletions framework_crates/bones_ecs/src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ impl Default for Entity {
///
/// It also holds a list of entities that were recently killed, which allows to remove components of
/// deleted entities at the end of a game frame.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, HasSchema)]
pub struct Entities {
/// Bitset containing all living entities
Expand Down

0 comments on commit 8fba451

Please sign in to comment.