Skip to content

Conversation

@urlyy
Copy link
Contributor

@urlyy urlyy commented Aug 26, 2025

Why?

Rust does not support objects being null; instead, it uses the Option type to wrap nullable objects. In the current Rust macros, Option<T> is extracted as MetaFieldType { name: "Option", generics: [T] }, and then compared with the MetaFieldType { name: T, generics: [] } received from the sender peer like java. This causes a type mismatch. Therefore, the Option type requires special handling.

What does this PR do?

  • support Option in MetaFieldType se/de. Specifically, during Rust peer serialization, I will serialize Option<T> as (T::type_id, nullable=true). During deserialization, (T::type_id, nullable=true) will be converted to Option<T>, while (T::type_id, nullable=false) will be converted to T.
  • correct the previous mistake in feat(Rust): Implementing Type Compatible #2492, rename FieldId to TypeId.

notice

It doesn’t support handling adjacent Options, such as Option<Option>.

Related issues

#2526

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

Copy link
Collaborator

@chaokunyang chaokunyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Could we add some incompatible tests cases in future.

For example, use a new class when deserialization with less fields

@chaokunyang chaokunyang merged commit 7cd4515 into apache:main Aug 26, 2025
101 of 107 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants