chaokunyang commented on code in PR #2815:
URL: https://github.com/apache/fory/pull/2815#discussion_r2454040278


##########
rust/fory-core/src/resolver/type_resolver.rs:
##########
@@ -816,4 +875,51 @@ impl TypeResolver {
     pub(crate) fn set_compatible(&mut self, compatible: bool) {
         self.compatible = compatible;
     }
+
+    pub fn get_actual_type_id<T: 'static + Serializer + ForyDefault>(&self) -> 
Result<u32, Error> {
+        let rs_type_id = std::any::TypeId::of::<T>();
+        if let Some(type_id) = self.actual_type_id_map.get(&rs_type_id) {
+            Ok(*type_id)
+        } else {
+            T::fory_get_type_id(self)
+        }
+    }
+
+    pub fn build(&self) -> Self {
+        Self {
+            type_info_map_by_id: self.type_info_map_by_id.clone(),
+            type_info_map: self.type_info_map.clone(),
+            type_info_map_by_name: self.type_info_map_by_name.clone(),
+            type_info_map_by_ms_name: self.type_info_map_by_ms_name.clone(),
+            type_id_index: self.type_id_index.clone(),
+            compatible: self.compatible,
+            actual_type_id_map: Default::default(),
+            registry: Default::default(),
+            once: Once::new(),
+            finalize_result: Default::default(),
+        }
+    }
+
+    pub(crate) fn finalize_registration(&mut self) -> Result<(), Error> {
+        let self_ref = Rc::new(RefCell::new(self));
+        ONCE.call_once(|| {
+            let funcs: Vec<_> = 
self_ref.borrow().registry.values().cloned().collect();
+            for func in funcs {
+                if let Err(e) = func(&mut self_ref.borrow_mut()) {
+                    let result = Err(e);
+                    GLOBAL_RETURN_VALUE.set(result).unwrap();
+                    return;
+                }
+            }
+            GLOBAL_RETURN_VALUE.set(Ok(())).unwrap();

Review Comment:
   Remove such code, too hacky



-- 
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]

Reply via email to