pub struct StringRepr {
pub encoding: StrEncoding,
pub endianness: Endianness,
pub len: StrLen,
}
Expand description
Controls the binary representation of strings.
Specifically, controls the StrEncoding
of strings and chars and the Endianness
in which the encoded bytes are ordered.
Keep in mind not all encodings support null terminated strings, because
the encoding format may have the capability to contain nulls.
In such cases, the encoding process will produce an error in case the encoded string contains
null characters, and the end of the string is encoded as a sequence of nulls of the appropriate
length (1 byte for UTF-8 and ASCII, 2 bytes for UTF-16, 4 bytes for UTF-32)
Fields§
§encoding: StrEncoding
§endianness: Endianness
§len: StrLen
Implementations§
Source§impl StringRepr
impl StringRepr
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Returns the default string representation: utf-8, length-prefixed, little_endian
Sourcepub const fn str_encoding(self, str_encoding: StrEncoding) -> Self
pub const fn str_encoding(self, str_encoding: StrEncoding) -> Self
Sets the string encoding, then returns self.
Sourcepub const fn endianness(self, endiannes: Endianness) -> Self
pub const fn endianness(self, endiannes: Endianness) -> Self
Sets the endianness, then returns self.
Sourcepub const fn len_encoding(self, len_encoding: StrLen) -> Self
pub const fn len_encoding(self, len_encoding: StrLen) -> Self
Sets the string length encoding, then returns self.
Trait Implementations§
Source§impl Clone for StringRepr
impl Clone for StringRepr
Source§fn clone(&self) -> StringRepr
fn clone(&self) -> StringRepr
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more