Skip to content

Feature: configurable string field type (e.g. smol_str::SmolStr), mirroring use_bytes_type #127

@uqio

Description

@uqio

buffa-build 0.6 has use_bytes_type() / use_bytes_type_in(&[paths]) to map proto bytesbytes::Bytes instead of Vec<u8>. There is no symmetric control for proto string: generated code always uses String.

Request: a parallel knob — e.g. use_string_type() / use_string_type_in(&[paths]) (or string_type(StringRepr)) — mapping proto string to a configurable immutable string type such as smol_str::SmolStr.

Motivation: We migrated a large hand-written proto3 surface (~138 messages) to buffa. The in-memory model is read-mostly and never mutates strings in place, so String's growable buffer is unnecessary; SmolStr gives inline storage for short strings (identifiers, codes, language tags) and O(1) clone for long ones, with no wire-format change. use_bytes_type already covers our bytes fields; string is the only remaining gap.

Implementation note: the codegen already parameterizes the field type for bytes via bytes_fields; a symmetric string_fields + chosen type appears to mirror that path. The selected type would need the same trait surface buffa relies on (Clone/PartialEq/Debug/Default, plus the serde and arbitrary impls already feature-gated like today's json/arbitrary). SmolStr satisfies these. No wire-encoding impact (UTF-8 bytes unchanged).

Happy to send a PR if the direction is acceptable.

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