The GitHub Actions job "Fory CI" on fory.git/main has succeeded.
Run started by GitHub user chaokunyang (triggered by chaokunyang).

Head commit for run:
a570c2f0d345d6de47f4dfb4c7cb73a285a45825 / Damon Zhao <[email protected]>
feat(rust): add tuple struct support and improve generic type handling (#3087)

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

Report URL: https://github.com/apache/fory/actions/runs/20498647170

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to