pub struct Text {
bytes: TextBytes,
}
Expand description
A byte array with each byte being a char. This is not UTF an must be constructed from a standard string.
Fields§
§bytes: TextBytes
Implementations§
source§impl Text
impl Text
sourcepub fn new_or_none(string: impl AsRef<str>) -> Option<Self>
pub fn new_or_none(string: impl AsRef<str>) -> Option<Self>
Create a Text
from an str
reference.
Returns None
if this string contains unsupported chars.
sourcepub fn new_or_panic(string: impl AsRef<str>) -> Self
pub fn new_or_panic(string: impl AsRef<str>) -> Self
Create a Text
from an str
reference.
Panics if this string contains unsupported chars.
sourcepub fn from_slice_unchecked(text: &TextSlice) -> Self
pub fn from_slice_unchecked(text: &TextSlice) -> Self
Create a Text
from a slice of bytes,
without checking any of the bytes.
sourcepub fn from_bytes_unchecked(bytes: TextBytes) -> Self
pub fn from_bytes_unchecked(bytes: TextBytes) -> Self
Create a Text
from the specified bytes object,
without checking any of the bytes.
sourcepub fn validate(
&self,
null_terminated: bool,
long_names: Option<&mut bool>,
) -> UnitResult
pub fn validate( &self, null_terminated: bool, long_names: Option<&mut bool>, ) -> UnitResult
Check whether this string is valid, adjusting long_names
if required.
If long_names
is not provided, text length will be entirely unchecked.
sourcepub fn validate_bytes(
text: &TextSlice,
null_terminated: bool,
long_names: Option<&mut bool>,
) -> UnitResult
pub fn validate_bytes( text: &TextSlice, null_terminated: bool, long_names: Option<&mut bool>, ) -> UnitResult
Check whether some bytes are valid, adjusting long_names
if required.
If long_names
is not provided, text length will be entirely unchecked.
sourcepub fn null_terminated_byte_size(&self) -> usize
pub fn null_terminated_byte_size(&self) -> usize
The byte count this string would occupy if it were encoded as a null-terminated string.
sourcepub fn i32_sized_byte_size(&self) -> usize
pub fn i32_sized_byte_size(&self) -> usize
The byte count this string would occupy if it were encoded as a size-prefixed string.
sourcepub fn write_i32_sized<W: Write>(&self, write: &mut W) -> UnitResult
pub fn write_i32_sized<W: Write>(&self, write: &mut W) -> UnitResult
Write the length of a string and then the contents with that length.
sourcefn write_unsized_bytes<W: Write>(bytes: &[u8], write: &mut W) -> UnitResult
fn write_unsized_bytes<W: Write>(bytes: &[u8], write: &mut W) -> UnitResult
Without validation, write this instance to the byte stream.
sourcepub fn read_i32_sized<R: Read>(read: &mut R, max_size: usize) -> Result<Self>
pub fn read_i32_sized<R: Read>(read: &mut R, max_size: usize) -> Result<Self>
Read the length of a string and then the contents with that length.
sourcepub fn read_sized<R: Read>(read: &mut R, size: usize) -> Result<Self>
pub fn read_sized<R: Read>(read: &mut R, size: usize) -> Result<Self>
Read the contents with that length.
sourcepub fn write_null_terminated<W: Write>(&self, write: &mut W) -> UnitResult
pub fn write_null_terminated<W: Write>(&self, write: &mut W) -> UnitResult
Write the string contents and a null-terminator.
sourcefn write_null_terminated_bytes<W: Write>(
bytes: &[u8],
write: &mut W,
) -> UnitResult
fn write_null_terminated_bytes<W: Write>( bytes: &[u8], write: &mut W, ) -> UnitResult
Write the string contents and a null-terminator.
sourcepub fn read_null_terminated<R: Read>(
read: &mut R,
max_len: usize,
) -> Result<Self>
pub fn read_null_terminated<R: Read>( read: &mut R, max_len: usize, ) -> Result<Self>
Read a string until the null-terminator is found. Then skips the null-terminator.
sourcefn read_vec_of_i32_sized(
read: &mut PeekRead<impl Read>,
total_byte_size: usize,
) -> Result<Vec<Text>>
fn read_vec_of_i32_sized( read: &mut PeekRead<impl Read>, total_byte_size: usize, ) -> Result<Vec<Text>>
Allows any text length since it is only used for attribute values, but not attribute names, attribute type names, or channel names.
sourcefn write_vec_of_i32_sized_texts<W: Write>(
write: &mut W,
texts: &[Text],
) -> UnitResult
fn write_vec_of_i32_sized_texts<W: Write>( write: &mut W, texts: &[Text], ) -> UnitResult
Allows any text length since it is only used for attribute values, but not attribute names, attribute type names, or channel names.
sourcepub fn chars(&self) -> impl '_ + Iterator<Item = char>
pub fn chars(&self) -> impl '_ + Iterator<Item = char>
Iterate over the individual chars in this text, similar to String::chars()
.
Does not do any heap-allocation but borrows from this instance instead.
sourcepub fn eq_case_insensitive(&self, string: &str) -> bool
pub fn eq_case_insensitive(&self, string: &str) -> bool
Compare this exr::Text
with a plain &str
ignoring capitalization.
Trait Implementations§
source§impl Ord for Text
impl Ord for Text
source§impl PartialEq<Text> for str
impl PartialEq<Text> for str
source§impl PartialEq for Text
impl PartialEq for Text
source§impl PartialOrd for Text
impl PartialOrd for Text
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Text
impl StructuralPartialEq for Text
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnwindSafe for Text
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.