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.
The new
__buffamodule structure introduced in 0.4.0 results in long, difficult to read paths for even the simplest of cases. For example, a message namedEventin a package namedtest, with a oneof namedpayloadresults intest::__buffa::oneof::event::Payload, when previously it would have beentest::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:
test::EventPayload. If this would result in a naming collision, an error thrown during codegen.__buffalocation.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
__buffamodules would be annotated with#[doc(hidden)]and the types within would be re-exported (withpub 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.