ariesdevil commented on code in PR #3080:
URL: https://github.com/apache/fory/pull/3080#discussion_r2644657377


##########
rust/fory-core/src/types.rs:
##########
@@ -95,8 +95,10 @@ pub enum TypeId {
     U64_ARRAY = 75,
     USIZE_ARRAY = 76,
     U128_ARRAY = 77,
+    INT128 = 78,
+    ISIZE = 79,

Review Comment:
   After my investigation, I think we need these type ids, if we remove these 
ids:
   
   ```rust
   // ser
   let value: usize = 42;
   let wrapped: Box<dyn Any> = Box::new(value);
   let bytes = fory.serialize(&wrapped).unwrap();
   
   // deser
   let result: Box<dyn Any> = fory.deserialize(&bytes).unwrap();
   let v = result.downcast_ref::<usize>().unwrap();  // <- will fail!
   ```
   
   Serialization:
     value: usize = 42
     Write TypeId = U64 (because on 64-bit systems usize == u64)
     Write data = 42
   
   Deserialization:
     Read TypeId = U64 (because we remove `usize` and `isize`)
     Fory looks up the type for U64 → finds u64
     Creates Box<dyn Any> containing a u64 value
     
   Downcast:
     result.downcast_ref::<usize>()  
     -> Internal type is u64, not usize
     -> Returns None!



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