2020-04-06 23:09:58 +00:00
|
|
|
[package]
|
2020-05-22 00:21:33 +00:00
|
|
|
name = "bevy_scene"
|
2024-07-08 12:54:08 +00:00
|
|
|
version = "0.15.0-dev"
|
2021-10-27 00:12:14 +00:00
|
|
|
edition = "2021"
|
2020-08-10 00:24:27 +00:00
|
|
|
description = "Provides scene functionality for Bevy Engine"
|
|
|
|
homepage = "https://bevyengine.org"
|
|
|
|
repository = "https://github.com/bevyengine/bevy"
|
2021-07-23 21:11:51 +00:00
|
|
|
license = "MIT OR Apache-2.0"
|
2020-08-10 00:24:27 +00:00
|
|
|
keywords = ["bevy"]
|
2020-04-06 23:09:58 +00:00
|
|
|
|
2022-11-14 23:08:22 +00:00
|
|
|
[features]
|
|
|
|
default = ["serialize"]
|
2024-06-10 16:37:59 +00:00
|
|
|
serialize = ["dep:serde", "uuid/serde", "bevy_ecs/serialize"]
|
2022-11-14 23:08:22 +00:00
|
|
|
|
2020-04-06 23:09:58 +00:00
|
|
|
[dependencies]
|
2020-08-10 00:39:28 +00:00
|
|
|
# bevy
|
2024-07-08 12:54:08 +00:00
|
|
|
bevy_app = { path = "../bevy_app", version = "0.15.0-dev" }
|
|
|
|
bevy_asset = { path = "../bevy_asset", version = "0.15.0-dev" }
|
|
|
|
bevy_derive = { path = "../bevy_derive", version = "0.15.0-dev" }
|
|
|
|
bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-dev" }
|
|
|
|
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [
|
2023-11-21 01:04:14 +00:00
|
|
|
"bevy",
|
|
|
|
] }
|
2024-07-08 12:54:08 +00:00
|
|
|
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.15.0-dev" }
|
|
|
|
bevy_transform = { path = "../bevy_transform", version = "0.15.0-dev" }
|
|
|
|
bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" }
|
|
|
|
bevy_render = { path = "../bevy_render", version = "0.15.0-dev", optional = true }
|
2020-05-29 22:51:36 +00:00
|
|
|
|
2020-08-10 00:39:28 +00:00
|
|
|
# other
|
2022-11-14 23:08:22 +00:00
|
|
|
serde = { version = "1.0", features = ["derive"], optional = true }
|
|
|
|
uuid = { version = "1.1", features = ["v4"] }
|
2024-12-06 17:03:55 +00:00
|
|
|
thiserror = { version = "2", default-features = false }
|
|
|
|
derive_more = { version = "1", default-features = false, features = ["from"] }
|
bevy_reflect: Binary formats (#6140)
# Objective
Closes #5934
Currently it is not possible to de/serialize data to non-self-describing formats using reflection.
## Solution
Add support for non-self-describing de/serialization using reflection.
This allows us to use binary formatters, like [`postcard`](https://crates.io/crates/postcard):
```rust
#[derive(Reflect, FromReflect, Debug, PartialEq)]
struct Foo {
data: String
}
let mut registry = TypeRegistry::new();
registry.register::<Foo>();
let input = Foo {
data: "Hello world!".to_string()
};
// === Serialize! === //
let serializer = ReflectSerializer::new(&input, ®istry);
let bytes: Vec<u8> = postcard::to_allocvec(&serializer).unwrap();
println!("{:?}", bytes); // Output: [129, 217, 61, 98, ...]
// === Deserialize! === //
let deserializer = UntypedReflectDeserializer::new(®istry);
let dynamic_output = deserializer
.deserialize(&mut postcard::Deserializer::from_bytes(&bytes))
.unwrap();
let output = <Foo as FromReflect>::from_reflect(dynamic_output.as_ref()).unwrap();
assert_eq!(expected, output); // OK!
```
#### Crates Tested
- ~~[`rmp-serde`](https://crates.io/crates/rmp-serde)~~ Apparently, this _is_ self-describing
- ~~[`bincode` v2.0.0-rc.1](https://crates.io/crates/bincode/2.0.0-rc.1) (using [this PR](https://github.com/bincode-org/bincode/pull/586))~~ This actually works for the latest release (v1.3.3) of [`bincode`](https://crates.io/crates/bincode) as well. You just need to be sure to use fixed-int encoding.
- [`postcard`](https://crates.io/crates/postcard)
## Future Work
Ideally, we would refactor the `serde` module, but I don't think I'll do that in this PR so as to keep the diff relatively small (and to avoid any painful rebases). This should probably be done once this is merged, though.
Some areas we could improve with a refactor:
* Split deserialization logic across multiple files
* Consolidate helper functions/structs
* Make the logic more DRY
---
## Changelog
- Add support for non-self-describing de/serialization using reflection.
Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
2022-11-04 02:22:54 +00:00
|
|
|
|
|
|
|
[dev-dependencies]
|
|
|
|
postcard = { version = "1.0", features = ["alloc"] }
|
|
|
|
bincode = "1.3"
|
2023-01-04 22:03:31 +00:00
|
|
|
rmp-serde = "1.1"
|
2023-11-18 20:58:48 +00:00
|
|
|
|
|
|
|
[lints]
|
|
|
|
workspace = true
|
2024-03-08 20:03:09 +00:00
|
|
|
|
|
|
|
[package.metadata.docs.rs]
|
2024-07-29 23:10:16 +00:00
|
|
|
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
|
2024-03-08 20:03:09 +00:00
|
|
|
all-features = true
|