Skip to content

New deeply nested oneof and view paths are difficult to use #80

@techninja1008

Description

@techninja1008

The new __buffa module structure introduced in 0.4.0 results in long, difficult to read paths for even the simplest of cases. For example, a message named Event in a package named test, with a oneof named payload results in test::__buffa::oneof::event::Payload, when previously it would have been test::event::Payload, which is much clearer.

The ideal solution would be configuration options to determine how oneof types/view types/extensions get generated. This would ideally offer all of the following modes:

  • Unambiguous (default): the behavior of 0.4.0
  • Simple: places types alongside their message, named after their message but with a suffix. Example from above would produce test::EventPayload. If this would result in a naming collision, an error thrown during codegen.
  • Simple with fallback: same as "Simple", however related/generated types that would collide with messages/enums are skipped, falling back to the default __buffa location.

Due to the need for consistent paths when paired with external code gen (eg. when a crate is being used with extern_paths), all modes other than "Unambiguous" would actually still generate the code in the same way as "Unambiguous", except the __buffa modules would be annotated with #[doc(hidden)] and the types within would be re-exported (with pub use) at their 'expected' locations. This means any code generated with a mode other than unambiguous would still be compatible with downstream codegen that expects types to be at their "unambiguous" locations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions