hanmanhui opened a new issue, #2913:
URL: https://github.com/apache/fory/issues/2913
### Question
Hi, I encountered a confusing behavior while using fory during
serialization/deserialization tests.
``` rust
#[test]
fn test_fory() {
#[derive(ForyObject, PartialEq, Debug)]
struct A {
x: u32,
y: String,
b: Vec<B>,
c: Option<C>,
}
#[derive(ForyObject, PartialEq, Debug)]
enum B {
Ba,
Bb,
}
#[derive(ForyObject, PartialEq, Debug)]
enum C {
Ca,
}
let mut fory = fory::Fory::default();
let _ = fory.register::<A>(1);
let _ = fory.register::<B>(2);
let bytes = fory.serialize(&B::Ba).expect("fory serialize failed");
let got: B = fory.deserialize(&bytes).expect("fory deserialize failed");
assert_eq!(got, B::Ba);
}
```
- output
``` bash
fory serialize failed: TypeError("Failed to build type resolver: TypeId
TypeId(0xf3c7b2e6678598a9b1fa4066d4f75fb5) not found in type_id_index, maybe
you forgot to register some types")
```
In this example, deserialization of B::Ba fails unless I also register type
C, even though C is only used inside A, not B.
This is the smallest reproducible case, but in my actual project, there are
over 100 types being registered.
When deserialization fails, it’s quite difficult to tell which type is
missing just from the error message, and finding the problematic one (like A in
this example) takes a lot of time.
It would be really helpful if there were a way to verify at test time
whether all required types have been registered correctly — for example, an API
like fory.is_registered::<T>() or a validation utility that ensures all
dependent types of a registered object are present.
Is there currently a recommended way to do this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]