PersistentDataContainers (PDC) Implementation #190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces
PersistentDataContainer
system to support per-entity, per-block, and other persistent data storage mechanisms within Ferrumc. This system is designed to allow developers to safely store and retrieve custom data across various server objects using a type-erased, flexible, and serializable structure.Key Features
PersistentDataContainer
Structure:serde_json::Value
) types, supporting flexible, type-safe serialization.type_map
for optional runtime type tracking (useful for debugging and ensuring type consistency).PersistentDataHolder
Trait:get_persistent_data
.edit_persistent_data
using a closure to ensure thread-safe and idiomatic data editing.PersistentDataContainer
supportsserde
serialization/deserialization to allow saving and loading persistent data easily work world files or other storage backends.HashMap<String, TypeId>
to track the expected type of each key at runtime if needed, improving safety and debugging visibility.Benefits
serde_json
for potential storage in NBT, JSON, or database formats.Example Usages
Future Improvements
get_as<T>
) and automatic casting.Notes
PersistentDataContainer
while leveraging Rust’s type system and memory safety guarantees.