summaryrefslogtreecommitdiff
path: root/engine-reflection/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-07-05 00:40:35 +0200
committerHampusM <hampus@hampusmat.com>2026-07-05 00:40:35 +0200
commitd10552031890ec09937d1b7a0dea1e68b0daf79a (patch)
treed19ccf66e6fbb5246cacee0b553794113295eee8 /engine-reflection/src
parent7f529801932fa98967b4dc959d4e9bb79511ff79 (diff)
feat(engine): add try_write_new_to fn to enum variant reflection
Diffstat (limited to 'engine-reflection/src')
-rw-r--r--engine-reflection/src/lib.rs21
1 files changed, 21 insertions, 0 deletions
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)]