Skip to content

feat: consider edge custom serde cases#6

Open
tisonkun wants to merge 3 commits into
mainfrom
patch-edge-cases
Open

feat: consider edge custom serde cases#6
tisonkun wants to merge 3 commits into
mainfrom
patch-edge-cases

Conversation

@tisonkun

@tisonkun tisonkun commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add normalized set-like ShapeRef::Union values for format-native alternatives;
  • replace ambiguous field shape state with composable Value, Flatten, Inline, and Omitted wire positions;
  • represent field-level custom serializers and deserializers as ShapeRef::Opaque, including flattened and transparent combinations;
  • model variant payloads as omitted, derived fields, or opaque custom content with function-path details;
  • update the environment-variable example and all shape snapshots for the new model.

Design notes

Union alternatives may overlap. Construction through ShapeRef::union or ShapeRef::try_union flattens nested unions, removes duplicates, sorts alternatives into canonical order, collapses singletons, and rejects empty input. The central public shape enums are non-exhaustive so future model additions do not require exhaustive downstream matches.

Field placement and value knowledge are independent: custom boundaries use ShapeRef::Opaque, so valid Serde combinations such as flatten + with become Flatten(Opaque(...)), while transparent custom fields become Inline(Opaque(...)). Redundant field and variant booleans are removed so the wire model has one source of truth.

Compatibility

This PR changes the public shape model. Consumers should migrate from value_shape and the separate skip, flatten, and custom flags to FieldWireShape; variant consumers should use the new direction-specific variant content enums. ShapeRef::OneOf is replaced by normalized ShapeRef::Union values created through the union constructors.

Validation

  • cargo x test
  • cargo +1.85.0 x test
  • cargo x lint
  • cargo x build --locked
  • real Serde and serde_json round-trip coverage for flatten + with, named transparent fields, transparent + with, and variant-level custom handlers

tisonkun added 3 commits June 24, 2026 01:19
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Normalize union alternatives, encode field placement independently from opaque custom boundaries, and retain custom variant content metadata. Add real Serde compatibility tests for flatten, transparent fields, and custom variants.

Signed-off-by: tison <wander4096@gmail.com>
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.

1 participant