#[non_exhaustive]pub enum RepeatedRepr {
Vec,
Custom(String),
}Expand description
The owned Rust collection a proto repeated field maps to in generated
owned structs.
The default is Vec (Vec<T>).
Custom substitutes any collection that satisfies
the buffa::ProtoList<T> bound — for example a crate-local newtype wrapping
a SmallVec-backed inline collection. Unlike the scalar string/bytes
knobs the custom collection wraps the element type, so its path is a
template containing a * placeholder where the element type is
substituted (e.g. "::my_crate::SmallList<*>").
The resolved collection must implement buffa::ProtoList<T>. Existing
implementations, including Vec<T>, work through aliases and associated
types. If neither buffa nor the collection’s defining crate supplies that
implementation, use a crate-local newtype to satisfy the orphan rule.
Select a representation through buffa_build’s repeated_type_custom
builder method. The wire format is identical regardless of the collection;
view types keep borrowing &[T].
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Vec
::buffa::alloc::vec::Vec<T> — the default. Keeps the Vec-specialized
fast paths (in-place push/reserve/clear, native Arbitrary)
instead of the generic ProtoList ones, so generated output for the
default is byte-identical to a build without the knob.
Custom(String)
A custom collection named by a Rust type-path template with a *
placeholder for the element type (e.g. "::my_crate::SmallList<*>"). The
named type must satisfy buffa::ProtoList<T>, whether through an existing
implementation or a crate-local newtype when the orphan rule
prevents adding that implementation directly.
§Limitations
- The template must contain at least one
*; the element type is substituted for every*before the result is parsed as a Rust type. A template that omits*surfaces asCodeGenError::MissingListPlaceholder, and one whose substitution is not a type path asCodeGenError::InvalidTypePath, at generation (.compile()) time. - Generated decode and clear code require
Field: ProtoList<T>. An associated type resolving toVec<T>already satisfies this; a foreign collection without an existing implementation needs a crate-local newtype even for binary-only generation. - Vtable reflection requires
buffa_descriptor’sReflectListon the selected collection; cleanup-profile borrowed inspection requiresInspectListinstead. Ordinary bridge reflection needs neither on the owned collection. JSON scalar, enum and policy helpers decode throughProtoList<T>and the element’s JSON traits, without requiring the collection’sDeserialize. Positions using ordinary serde instead, including message elements and unlisted custom string elements, require the collection’sSerialize/Deserialize. Arbitrary generation requires the selected field or builder’s correspondingarbitraryintegration. - A
repeated <self-type>field becomesCollection<Self>, so the collection must be heap-backed; an inline collection (SmallVec<[Self; N]>) would be infinitely sized and fail to compile.