summaryrefslogtreecommitdiff
path: root/engine-reflection
diff options
context:
space:
mode:
Diffstat (limited to 'engine-reflection')
-rw-r--r--engine-reflection/Cargo.toml2
-rw-r--r--engine-reflection/src/lib.rs21
2 files changed, 23 insertions, 0 deletions
diff --git a/engine-reflection/Cargo.toml b/engine-reflection/Cargo.toml
index 8e13728..2f90841 100644
--- a/engine-reflection/Cargo.toml
+++ b/engine-reflection/Cargo.toml
@@ -4,3 +4,5 @@ version = "0.1.0"
edition = "2021"
[dependencies]
+thiserror = "1.0.49"
+
diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs
index 9f347fa..3451442 100644
--- a/engine-reflection/src/lib.rs
+++ b/engine-reflection/src/lib.rs
@@ -177,6 +177,27 @@ pub struct EnumVariant
pub fields: Option<EnumVariantFields>,
pub discriminant: EnumDiscriminant,
+
+ pub try_write_new_to: fn(
+ dst: &mut dyn Any,
+ fields: &mut dyn Iterator<Item = Box<dyn Any>>,
+ ) -> Result<(), EnumVariantWriteNewToError>,
+}
+
+#[derive(Debug, thiserror::Error)]
+pub enum EnumVariantWriteNewToError
+{
+ #[error("Destination must be the same type as the variant's enum")]
+ WrongDstType,
+
+ #[error("Too few fields are specified")]
+ TooFewFields,
+
+ #[error("Too many fields are specified")]
+ TooManyFields,
+
+ #[error("A field has the wrong type")]
+ WrongFieldType,
}
#[derive(Debug, Clone)]