Skip to content

Commit

Permalink
Merge pull request #220 from alyjak/make_CustomEntitySerializer_public
Browse files Browse the repository at this point in the history
Adds CustomEntitySerializer to the public API
  • Loading branch information
TomGillen authored Dec 13, 2020
2 parents 7be9eca + 17bb861 commit dbba5e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/internals/serialize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub enum UnknownType {

/// Describes how to serialize and deserialize a runtime `Entity` ID.
pub trait CustomEntitySerializer {
/// The type used for serialized Entity IDs. Developers should be aware of their
/// serialization/deserialization use-cases as well as world-merge use cases when picking a
/// SerializedID, as the SerializedId type must identify unique entities across world
/// serialization/deserialization cycles as well as across world merges.
type SerializedID: serde::Serialize + for<'a> serde::Deserialize<'a>;
/// Constructs the serializable representation of `Entity`
fn to_serialized(&mut self, entity: Entity) -> Self::SerializedID;
Expand Down
3 changes: 2 additions & 1 deletion src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ pub use crate::internals::serialize::{
de::WorldDeserializer,
id::{Canon, EntityName, EntitySerializer},
ser::{SerializableWorld, WorldSerializer},
AutoTypeKey, DeserializeIntoWorld, DeserializeNewWorld, Registry, TypeKey, UnknownType,
AutoTypeKey, CustomEntitySerializer, DeserializeIntoWorld, DeserializeNewWorld, Registry,
TypeKey, UnknownType,
};

#[cfg(feature = "type-uuid")]
Expand Down

0 comments on commit dbba5e9

Please sign in to comment.