#[non_exhaustive]pub enum StringRepr {
String,
SmolStr,
EcoString,
CompactString,
}Expand description
The Rust type a proto string field maps to in generated owned structs.
The default is String. The other variants are
small-string-optimized types that avoid String’s growable buffer for
read-mostly schemas; each is gated behind the matching buffa Cargo feature
(smol_str, ecow, compact_str), and the downstream crate must enable
that feature so the re-exported type path (::buffa::smol_str::SmolStr,
etc.) resolves.
Select a representation through buffa_build’s string_type /
string_type_in 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.
Sizes below are for 64-bit targets. See the buffa README for a fuller comparison of the small-string crates.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
String
::buffa::alloc::string::String — 24-byte struct, growable and mutable
(the default).
SmolStr
smol_str::SmolStr — 24-byte struct, inlines up to 23 bytes, O(1)
clone of long strings via Arc<str>. Immutable (assign a new value
to mutate). Requires the buffa/smol_str feature.
EcoString
ecow::EcoString — 16-byte struct, inlines up to 15 bytes, clone-on-write
with O(1) clone. Immutable (assign a new value to mutate).
Requires the buffa/ecow feature.
CompactString
compact_str::CompactString — 24-byte struct, inlines up to 24 bytes,
mutable (a drop-in String replacement). Requires the
buffa/compact_str feature.
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
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 ==.