Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exhaustive internally tagged tests + support of internally tagged enums in non self-describing formats #2569

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Commits on Oct 22, 2024

  1. Explain code in ContentDeserializer::deserialize_newtype_struct and a…

    …dd comments about coverage
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    397e871 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    90564e6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a1e4ce7 View commit details
    Browse the repository at this point in the history
  4. Remove confusing call to deserialize_untagged_variant in deserialize_…

    …internally_tagged_variant
    
    deserialize_untagged_variant in that place is called when deserialzie_with attribute is set.
    In that case it performs special actions that is better to use explicitly in deserialize_untagged_variant
    for readability
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    6929c5d View commit details
    Browse the repository at this point in the history
  5. Add test for sequence in newtype_unit

    failures(1):
        newtype_unit
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    ec5f590 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    bcffa60 View commit details
    Browse the repository at this point in the history
  7. Consistently use visit_content_seq and visit_content_map when deseria…

    …lize enums
    
    Helper methods visit_content_[seq|map] does the same as [Seq|Map]Deserializer::deserialize_any
    and used everywhere except here. Reuse them for consistency
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    5292da8 View commit details
    Browse the repository at this point in the history
  8. Deserializer should not check correctness of data, this is the respon…

    …sibility of the Visitor
    
    Examples of errors produced during deserialization of internally tagged enums in tests
    if instead of a Seq/Map a Str("unexpected string") will be provided:
    
    In tests/test_annotations.rs
      flatten::enum_::internally_tagged::tuple:
        before: `invalid type: string "unexpected string", expected tuple variant`
        after : `invalid type: string "unexpected string", expected tuple variant Enum::Tuple`
    
      flatten::enum_::internally_tagged::struct_from_map:
        before: `invalid type: string "unexpected string", expected struct variant`
        after : `invalid type: string "unexpected string", expected struct variant Enum::Struct`
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    9009f63 View commit details
    Browse the repository at this point in the history
  9. Store deserializer in Enum[Ref]Deserializer and Variant[Ref]Deseriali…

    …zer directly
    
    That is cheap, creating a Content[Ref]Deserializer is a no-op
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    bf09ca4 View commit details
    Browse the repository at this point in the history
  10. cargo fmt

    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    020dace View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    55e1c22 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    2ba21c8 View commit details
    Browse the repository at this point in the history
  13. Add support for internally tagged enums in non self-describing formats

    Deserializer methods are only hints which deserializer is not obliged to follow.
    Both TaggedContentVisitor and InternallyTaggedUnitVisitor accepts only
    visit_map and visit_seq and that is what derived implementation of Deserialize
    does for structs. Therefore it is fine to call deserialize_map here, as that
    already did in derived deserialize implementation
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    4c28350 View commit details
    Browse the repository at this point in the history
  14. Add support for struct variants in untagged and adjacently tagged enu…

    …ms in non self-describing formats
    
    Visitor passed to the deserialize_any supports only visit_map method,
    so we can always request deserialize_map
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    72a7401 View commit details
    Browse the repository at this point in the history
  15. Use deserialize_unit instead of deserialize_any for unit variants of …

    …untagged and adjacently tagged enums
    Mingun committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    9702ce1 View commit details
    Browse the repository at this point in the history