ariesdevil opened a new pull request, #3087: URL: https://github.com/apache/fory/pull/3087
<!-- **Thanks for contributing to Apache Fory™.** **If this is your first time opening a PR on fory, you can refer to [CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).** Contribution Checklist - The **Apache Fory™** community has requirements on the naming of pr titles. You can also find instructions in [CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md). - Apache Fory™ has a strong focus on performance. If the PR you submit will have an impact on performance, please benchmark it first and provide the benchmark result here. --> ## Why? To support serialization of tuple struct and improve generic type in Rust. After this PR, we can finally support fory for [OpenRaft](https://github.com/databendlabs/openraft) ## What does this PR do? This PR adds tuple struct serialization support and improves generic type handling in `fory-derive`. ### 1. Tuple Struct Support Previously, `#[derive(ForyObject)]` only supported named structs. Now it also supports tuple structs: ```rust use fory_derive::ForyObject; // Tuple struct with multiple fields #[derive(ForyObject, Debug, PartialEq)] struct Point(f64, f64); // Single field wrapper #[derive(ForyObject, Debug, PartialEq)] struct UserId(u64); // Complex tuple struct #[derive(ForyObject, Debug, PartialEq)] struct Record(i32, String, Vec<u8>); fn main() { let mut fory = Fory::default(); fory.register::<Point>(100).unwrap(); let point = Point(3.5, 4.5); let bytes = fory.serialize(&point).unwrap(); let result: Point = fory.deserialize(&bytes).unwrap(); assert_eq!(result, point); } ``` ### 2. Improved Generic Type Handling - Fixed field ordering for tuple structs (must preserve original order, not sort by type) - Better fingerprint computation for struct versioning - Improved type parameter detection in generic types ## Related issues None ## Does this PR introduce any user-facing change? - [x] Does this PR introduce any public API change? - Yes, adds new public types support: tuple struct - [ ] Does this PR introduce any binary protocol compatibility change? - No ## Benchmark <!-- When the PR has an impact on performance (if you don't know whether the PR will have an impact on performance, you can submit the PR first, and if it will have impact on performance, the code reviewer will explain it), be sure to attach a benchmark data here. Delete section if not applicable. --> -- 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]
