urlyy commented on code in PR #2798:
URL: https://github.com/apache/fory/pull/2798#discussion_r2453782681
##########
rust/fory-core/src/resolver/type_resolver.rs:
##########
@@ -813,7 +934,117 @@ impl TypeResolver {
self.register_internal_serializer::<T>(type_id)
}
+ pub fn do_register(&mut self, type_id: std::any::TypeId) -> Result<(),
Error> {
+ assert!(!self.registered_types.contains(&type_id));
+ let registry_ptr: *mut Self = self;
+ let register_fn = self.registry.get(&type_id);
+ match register_fn {
+ Some(register_fn) => {
+ unsafe {
+ register_fn(&mut *registry_ptr)?;
+ }
+ self.registered_types.insert(type_id);
+ Ok(())
+ }
+ None => Err(Error::type_error(format!(
+ "TypeId {:?} not found in type_id_index, maybe you forgot to
register some types",
+ type_id
+ ))),
+ }
+ }
+
pub(crate) fn set_compatible(&mut self, compatible: bool) {
self.compatible = compatible;
}
}
+
+pub struct SharedTypeResolver {
Review Comment:
I will open a new pr to handle this issue
--
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]