You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, all the entities in the world get serialized. It's useful to only serialize a subset of them, though. For example, to save on network bandwidth, disk space, or if some entities are generated from some other data source and there's not much point to serialize them.
The most obvious way would be to add a is_serializable(EntityRef)->bool function to SerializeContext trait. Then in the serialize function it should be called for every entity and if it returns false, the whole entity is skipped.
While I understand it's relatively easy to implement outside of the library(I've already done so), I think it's common enough use case that it's worth to consider including it in the library.
The text was updated successfully, but these errors were encountered:
Given the utterly trivial implementation, I have no objection to providing this. In general, my stance on externally-implementable functionality has softened to including conveniences when they're sufficiently helpful and strongly encapsulated.
Taking a slightly closer look at this, there's a wrinkle: skipping entities makes it harder to know in advance how many entities will be serialized. We could stop supplying a known length to the relevant serialize_map call and break serializers that depend on it, e.g. bincode, or we could make two passes over the world, which feels pretty ugly.
While neither of those are disasters, the optimal tradeoff will vary from application to application, which weakens the case for providing this behavior out-of-the-box. The serialization code is after all intended to be simple and easy to get good results with and serve as example code for custom solutions, not to address every use case itself.
Right now, all the entities in the world get serialized. It's useful to only serialize a subset of them, though. For example, to save on network bandwidth, disk space, or if some entities are generated from some other data source and there's not much point to serialize them.
The most obvious way would be to add a
is_serializable(EntityRef)->bool
function toSerializeContext
trait. Then in theserialize
function it should be called for every entity and if it returns false, the whole entity is skipped.While I understand it's relatively easy to implement outside of the library(I've already done so), I think it's common enough use case that it's worth to consider including it in the library.
The text was updated successfully, but these errors were encountered: