How to serialize components with Entity fields?
- 主要语言
- Rust
- 星标
- 1.7k
- 派生
- 140
- PR 合并指标
- 30 天内没有已合并 PR
描述
Suppose I have some kind of Component struct with a `target: Entity` field on it. If I `[derive(Serialize, Deserialize)]` on that struct, what I discover is that Entity is not (de)serializable.
```
error[E0277]: the trait bound `legion_core::entity::Entity: components::_IMPL_DESERIALIZE_FOR_Position::_serde::Deserialize<'_>` is not satisfied
--> src/components.rs:195:5
|
195 | pub item: Entity,
| ^^^ the trait `components::_IMPL_DESERIALIZE_FOR_Position::_serde::Deserialize<'_>` is not implemented for `legion_core::entity::Entity`
|
= note: required by `components::_IMPL_DESERIALIZE_FOR_Position::_serde::de::MapAccess::next_value`
```
I recall that in specs there was quite a bit of boilerplate involving markers to get this to work. Unfortunately the documentation is not yet present for serialize (which in fact is in master, but is not yet published on crates.io, which is 6 months behind master). The lone example has a _lot_ of boilerplate code which doesn't seem game-specific (should it be part of the library?), including some unsafe, but gives no examples of de/serializing any Entity.
Can we get an example of that?
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。