pub enum StringTypeMode {
Owned,
Borrowed,
}Expand description
Controls whether string and binary ASN.1 types are generated as owned heap-allocating types or as zero-copy borrowed references.
The following ASN.1 types have both an owned form and a zero-copy Ref
variant and are therefore affected by this setting:
| ASN.1 type | Owned (Owned mode) | Borrowed (Borrowed mode) |
|---|---|---|
OCTET STRING | OctetString | OctetStringRef<'a> |
BIT STRING | BitString | BitStringRef<'a> |
UTF8String | Utf8String | Utf8StringRef<'a> |
PrintableString | PrintableString | PrintableStringRef<'a> |
IA5String | IA5String | IA5StringRef<'a> |
Types that have no zero-copy variant (TeletexString, BmpString,
UniversalString, GeneralString, NumericString, VisibleString) are
always emitted as owned types regardless of this setting.
Named bit strings (BIT STRING { flag(0), … }) are always emitted as
owned BitString regardless of this setting because they are decoded into
a concrete bit-field type.
StringTypeMode::Owned(default): heap-allocates on decode; convenient for constructing structs from scratch (e.g. in tests or protocol message builders).StringTypeMode::Borrowed: borrows directly from the input buffer; optimal for parse-only workloads such as X.509 certificate inspection. Every struct that contains these fields (directly or transitively) gains a'alifetime parameter.
Variants§
Owned
Generate owned, heap-allocating types (OctetString, BitString, …).
No lifetime parameter is added to generated structs.
Borrowed
Generate zero-copy borrowed types (OctetStringRef<'a>, BitStringRef<'a>, …)
that borrow from the decoder’s input buffer.
Structs containing these fields acquire a 'a lifetime parameter.
Trait Implementations§
Source§impl Clone for StringTypeMode
impl Clone for StringTypeMode
Source§fn clone(&self) -> StringTypeMode
fn clone(&self) -> StringTypeMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more