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.
Utf32Strings 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 chars (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§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Utf32String
impl Debug for Utf32String
Source§impl Default for Utf32String
impl Default for Utf32String
Source§fn default() -> Utf32String
fn default() -> Utf32String
Source§impl Display for Utf32String
impl Display for Utf32String
Source§impl Hash for Utf32String
impl Hash for Utf32String
Source§impl PartialEq for Utf32String
impl PartialEq for Utf32String
Source§impl TryFrom<&[char]> for Utf32String
impl TryFrom<&[char]> for Utf32String
Source§impl TryFrom<&String> for Utf32String
impl TryFrom<&String> for Utf32String
Source§impl TryFrom<&str> for Utf32String
impl TryFrom<&str> for Utf32String
Source§impl TryFrom<String> for Utf32String
impl TryFrom<String> for Utf32String
impl Eq for Utf32String
impl StructuralPartialEq for Utf32String
Auto Trait Implementations§
impl !Freeze for Utf32String
impl RefUnwindSafe for Utf32String
impl Send for Utf32String
impl Sync for Utf32String
impl Unpin for Utf32String
impl UnwindSafe for Utf32String
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)