跳到主要内容

Fory v0.13.1 Released

· 阅读需 4 分钟
Shawn Yang

The Apache Fory team is pleased to announce the 0.13.1 release. This is a release that includes 28 PR from 11 distinct contributors. See the Install Page to learn how to get the libraries for your platform.

Highlights

  • Support rust enum variant and schema evolution for tuple/struct style enum
  • Support rust tuple serialization and schema evolution
  • Support rust skip macro attributes

Enum Schema Evolution

Fory v0.13.1 adds comprehensive enum schema evolution in Compatible mode, supporting all three variant types (Unit, Unnamed, Named):

  • Add/remove variants: Unknown variants fall back to #[fory(default)]
  • Add/remove fields: Named variants support field evolution with automatic defaults
  • Modify elements: Unnamed variants handle element count changes (extras skipped, missing use defaults)
  • Variant type changes: Convert between Unit/Unnamed/Named with automatic default values
// Version 1
#[derive(ForyObject)]
enum Command {
#[fory(default)]
Noop,
Execute { name: String, args: i32 },
}

// Version 2 - Added field and new variant
// both `fory(default)` and standard `default` are supported
#[derive(Default, ForyObject)]
enum Command {
#[default]
Noop,
Execute { name: String, args: i32, env: String }, // Added 'env'
Cancel { reason: String }, // New variant
}

// V1→V2: Missing 'env' gets default ""; Cancel→Noop fallback in V1
// V2→V1: Extra 'env' skipped; Cancel→Noop fallback

Tuple Schema Evolution

Tuples (1-22 elements) now support length evolution in Compatible mode:

  • Length changes: Grow or shrink tuple size (missing elements get defaults, extras discarded)
  • Collections: Vec, HashMap, HashSet elements fully supported
  • Nested tuples: Multi-level nesting with independent evolution per level
  • Smart pointers: Option, Arc, Rc wrapped elements handle evolution correctly
  • Struct fields: Tuple fields in structs evolve independently
let fory = Fory::default().compatible(true);

// Serialize 2-element tuple
let short = (42i32, "hello".to_string());
let bin = fory.serialize(&short).unwrap();

// Deserialize as 4-element tuple - extras get defaults
let long: (i32, String, f64, bool) = fory.deserialize(&bin).unwrap();
assert_eq!(long, (42, "hello".to_string(), 0.0, false));

// Reverse: 4→2 elements, extras discarded
let long = (100i32, "world".to_string(), 3.14, true);
let bin = fory.serialize(&long).unwrap();
let short: (i32, String) = fory.deserialize(&bin).unwrap();
assert_eq!(short, (100, "world".to_string()));

Features

Bug Fix

Other Improvements

New Contributors

Full Changelog: https://github.com/apache/fory/compare/v0.13.0...v0.13.1