urlyy opened a new pull request, #2699:
URL: https://github.com/apache/fory/pull/2699

   ## What does this PR do?
   
   1. Added many unit tests, which should ensure the correctness of the 
protocol implementation.
   2. Added benchmark code for string_data writing.
   3. Implemented skipping for `named_xx`.
   4. Implemented `write_namespace`/`typename` in `Consistent` mode (unit tests 
not completed due to `structHash` not being implemented).
   5. Added sorting of fields when reading in `TypeMeta``.
   
   
   ## Related issues
   
   
   ## Does this PR introduce any user-facing change?
   fory support util func to write/read
   ```rust
   pub fn write<T: Serializer>(
       this: &T,
       context: &mut WriteContext,
       is_field: bool,
       skip_ref_flag: bool,
       skip_type_info: bool,
   ) {
       write_ref_info_data(this, context, is_field, skip_ref_flag, 
skip_type_info);
   }
   
   pub fn read<T: Serializer>(
       context: &mut ReadContext,
       is_field: bool,
       skip_ref_flag: bool,
       skip_type_info: bool,
   ) -> Result<T, Error> {
       read_ref_info_data(context, is_field, skip_ref_flag, skip_type_info)
   }
   ```
   use customized serializer like this:
   ```
   #[derive(Debug, PartialEq, Default)]
   struct MyExt {
       id: i32,
   }
   impl Serializer for MyExt {
       fn fory_write_data(&self, context: &mut WriteContext, _is_field: bool) {
           // set is_field=false to write type_id like in java xwriteRef 
           write(&self.id, context, false, false, false);
       }
   
     fn fory_read_data(context: &mut ReadContext, _is_field: bool) -> 
Result<Self, Error> {
         Ok(Self {
             // set is_field=false to write type_id like in java xreadRef
             id: read(context, false, false, false)?,
         })
     }
   }
   ```
   
   - [ ] Does this PR introduce any public API change?
   - [ ] Does this PR introduce any binary protocol compatibility change?


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