feat(rust): support configure rust field meta to reduce cost #3089
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why?
This PR implements field-level optimization attributes for Rust, enabling users to control serialization behavior at the field level. This reduces serialization overhead by:
What does this PR do?
New Field Attributes
Adds support for
#[fory(...)]field attributes with the following options:id = NnullabletrueforOption<T>,RcWeak<T>,ArcWeak<T>;falseotherwisereftrueforRc<T>,Arc<T>,RcWeak<T>,ArcWeak<T>;falseotherwiseskipfalseUsage Examples
Compact Field ID Encoding
Per xlang_serialization_spec.md, field IDs use TAG_ID encoding:
This provides ~28% smaller payload compared to field name encoding for structs with explicit field IDs.
Implementation Details
field_meta.rs: New module for parsing#[fory(...)]attributestype_meta.rs: UpdatedFieldInfowithnew_with_id()constructor and compact encodingmisc.rs: Generates field metadata with nullable/ref_tracking/field_idutil.rs: Updated fingerprint computation to include field metadataRelated issues
Closes #3004
#1017
Does this PR introduce any user-facing change?
#[fory(...)]field attributesBenchmark
Field ID encoding produces ~28% smaller payloads: