theweipeng opened a new pull request, #1795:
URL: https://github.com/apache/fury/pull/1795

   ## What does this PR do?
   1. Support polymorphism
   Add a class resolver which is used for managing the relationship between 
type_id and serializer. The serializer is generated by a generic function which 
will be called by dynamic dispatch. When a struct uses `Box<dyn Any>` as a 
field type and does not specify the specific type, we will use the class 
resolver to load the handler by type_id. In this situation, there is some 
performance overhead due to hash lookup, but it greatly improves convenience.
   Use as follow:
   ```Rust
   #[test]
   fn any() {
       #[derive(Fury, Debug)]
       struct Animal {
           f3: String,
       }
   
       #[derive(Fury, Debug)]
       struct Person {
           f1: Box<dyn Any>,
       }
   
       let person = Person {
           f1: Box::new(Animal {
               f3: String::from("hello"),
           }),
       };
   
       let mut fury = Fury::default();
       fury.register::<Animal>(999);
       fury.register::<Person>(1000);
       let bin = fury.serialize(&person);
       let obj: Person = fury.deserialize(&bin).expect("");
       assert_eq!(true, obj.f1.is::<Animal>())
   }
   
   ```
   2. Add a register  function for user to register Struct and id
   3. Remove tag and hash which were generate by macro before and were removed 
in our protocol now.


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