pub struct Utf32String(/* private fields */);
Expand description
A string encoded as UTF-32.
Strings of this type can be serialized into a story file (via the
Item::Utf32String
constructor) formatted
compatibly with the streamstr
instruction. Constructors ensure that the
string is valid Unicode with no embedded nulls. Internally it’s a Bytes
,
so cloning it is cheap.
This is not at all a full-featured alternative to std::String
.
Utf32String
s are immutable once constructed and not intended for anything
other than being serialized into a story file.
Implementations§
Source§impl Utf32String
impl Utf32String
Sourcepub fn from_chars<I, C>(chars: I) -> Result<Self, StringConversionError<Self>>
pub fn from_chars<I, C>(chars: I) -> Result<Self, StringConversionError<Self>>
Construct a Utf32String
from an iterator over char
s (or over any type
that lets you borrow a char
).
If the string contains embedded nulls, an error is returned, but a lossy
version can be extracted from the error struct. The lossy string
replaces nulls with U+2400 SYMBOL FOR NULL
(␀), which belongs to the
Control Pictures block, which is a really neat block that I bet you
didn’t know existed.
Sourcepub fn from_chars_lossy<I, C>(chars: I) -> Self
pub fn from_chars_lossy<I, C>(chars: I) -> Self
Like from_chars
, but in case of error will
silently unwrap the error and return the lossy version.
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Returns the length of the string in bytes, excluding prefix and null terminator.
Sourcepub fn byte_len_with_prefix_and_nul(&self) -> usize
pub fn byte_len_with_prefix_and_nul(&self) -> usize
Returns the length of the string in bytes, including prefix and null terminator.
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Unwraps the string into its underlying Bytes
.
Trait Implementations§
Source§impl Clone for Utf32String
impl Clone for Utf32String
Source§fn clone(&self) -> Utf32String
fn clone(&self) -> Utf32String
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more