#[non_exhaustive]pub enum StringRepr {
String,
Custom(String),
}Expand description
The Rust type a proto string field maps to in generated owned structs.
The default is String.
Custom substitutes any type named by its
fully-qualified Rust path — for example ::smol_str::SmolStr,
::ecow::EcoString, or ::compact_str::CompactString for read-mostly
schemas — that satisfies the buffa::ProtoString bound. The downstream crate
must itself depend on the crate providing that type (buffa does not re-export
it).
Select a representation through buffa_build’s string_type /
string_type_custom builder methods. The wire format is identical regardless
of representation — only the in-memory owned type changes; view types keep
borrowing &str, and map<_, string> / map<string, _> keys and values
always stay String.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
String
::buffa::alloc::string::String — growable and mutable (the default).
Custom(String)
A custom type named by its fully-qualified Rust path (e.g.
"::smol_str::SmolStr"). Must satisfy buffa::ProtoString and be
provided by a crate the downstream depends on.
§Limitations
- A foreign custom type used as a
repeatedelement fails to compile (the emittedReflectElementimpl violates the orphan rule). Wrap it in a crate-local newtype for that case; singular / optional / oneof / map uses work with a foreign type directly. - A path that does not parse as a Rust type surfaces as
CodeGenError::InvalidTypePathat generation (.compile()) time. - The per-element impls are deduplicated within a single generation, but
the same crate-local type used as a
repeatedelement across two separatecompile()invocations in one crate emits the impl twice (a duplicate-implE0119). Generate from a singlecompile(), or use distinct element types.
Trait Implementations§
Source§impl Clone for StringRepr
impl Clone for StringRepr
Source§fn clone(&self) -> StringRepr
fn clone(&self) -> StringRepr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StringRepr
impl Debug for StringRepr
Source§impl Default for StringRepr
impl Default for StringRepr
Source§fn default() -> StringRepr
fn default() -> StringRepr
impl Eq for StringRepr
Source§impl PartialEq for StringRepr
impl PartialEq for StringRepr
Source§fn eq(&self, other: &StringRepr) -> bool
fn eq(&self, other: &StringRepr) -> bool
self and other values to be equal, and is used by ==.