urlyy commented on issue #3049:
URL: https://github.com/apache/fory/issues/3049#issuecomment-3657202258

   At present, Fory-Rust only writes metadata for internal generic types when 
handling the three container types—List, Set, and Map—and does not process 
generics defined on structs. It appears that the sender’s and receiver’s 
`TypeMeta` are inconsistent, which further leads to a series of issues and 
ultimately results in errors.
   
   You can find more details in the quoted code block below.
   
   
https://github.com/apache/fory/blob/423b8775d8921a30aa4bdf3d132520ec806a1641/rust/fory-core/src/meta/type_meta.rs#L106-L179
   
   I made a small tentative fix (not the final solution).
   ```rust
   fn to_bytes(&self, writer: &mut Writer, write_flag: bool, nullable: bool) -> 
Result<(), Error> {
      .............
       match self.type_id {
          ......................
           x if [TypeId::EXT as u32, TypeId::COMPATIBLE_STRUCT as 
u32].contains(&(x & 0xff)) => {
               writer.write_u8(self.generics.len() as u8);
               for generic in self.generics.iter() {
                   generic.to_bytes(writer, true, generic.nullable)?;
               }
           }
           _ => {}
       }
       Ok(())
   }
   
   fn from_bytes(
       reader: &mut Reader,
       read_flag: bool,
       nullable: Option<bool>,
   ) -> Result<Self, Error> {
      ......................
       Ok(match type_id {
          ................
           x if [TypeId::EXT as u32, TypeId::COMPATIBLE_STRUCT as 
u32].contains(&(x & 0xff)) => {
               let mut generics = vec![];
               let len = reader.read_u8()?;
               for _ in 0..len {
                   generics.push(Self::from_bytes(reader, true, None)?);
               }
               Self {
                   type_id,
                   nullable: _nullable,
                   generics,
               }
           }
           _ => Self {
               type_id,
               nullable: _nullable,
               generics: vec![],
           },
       })
   }
   ```
   And it passed the unit test. 
   However, I am not entirely sure whether this aligns with @chaokunyang 
intentions. Do you think this approach is acceptable?


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