[x] I've added tests for all code changes and additions (where applicable)
[x] I've added a demonstration of the new feature to one or more examples
[x] I've updated the book to reflect my changes
[x] Usage of new public items is shown in the API docs
API changes
This change modifies the behavior of serialize to calculate the count of items before handing off to the serde serializer. The majority of formats that serde supports require a known count to prefix the data with. (i.e. bincode, msgpack). Most of these will fail serialization immediatly when trying to use them with component serialization.
There is additional overhead from calculating the number of items but the cost appears to be trivial in comparison to the time spent on serialization.
I did not modify serialize_recusive as it would require a much more expensive double-traversal of the data structures inspecting for contained entities.
Checklist
API changes
This change modifies the behavior of serialize to calculate the count of items before handing off to the serde serializer. The majority of formats that serde supports require a known count to prefix the data with. (i.e. bincode, msgpack). Most of these will fail serialization immediatly when trying to use them with component serialization.
There is additional overhead from calculating the number of items but the cost appears to be trivial in comparison to the time spent on serialization.
I did not modify serialize_recusive as it would require a much more expensive double-traversal of the data structures inspecting for contained entities.