Struct exr::meta::attribute::Text

source ·
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

source

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.

source

pub fn new_or_panic(string: impl AsRef<str>) -> Self

Create a Text from an str reference. Panics if this string contains unsupported chars.

source

pub fn from_slice_unchecked(text: &TextSlice) -> Self

Create a Text from a slice of bytes, without checking any of the bytes.

source

pub fn from_bytes_unchecked(bytes: TextBytes) -> Self

Create a Text from the specified bytes object, without checking any of the bytes.

source

pub fn as_slice(&self) -> &TextSlice

The internal ASCII bytes this text is made of.

source

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.

source

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.

source

pub fn null_terminated_byte_size(&self) -> usize

The byte count this string would occupy if it were encoded as a null-terminated string.

source

pub fn i32_sized_byte_size(&self) -> usize

The byte count this string would occupy if it were encoded as a size-prefixed string.

source

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.

source

fn write_unsized_bytes<W: Write>(bytes: &[u8], write: &mut W) -> UnitResult

Without validation, write this instance to the byte stream.

source

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.

source

pub fn read_sized<R: Read>(read: &mut R, size: usize) -> Result<Self>

Read the contents with that length.

source

pub fn write_null_terminated<W: Write>(&self, write: &mut W) -> UnitResult

Write the string contents and a null-terminator.

source

fn write_null_terminated_bytes<W: Write>( bytes: &[u8], write: &mut W, ) -> UnitResult

Write the string contents and a null-terminator.

source

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.

source

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.

source

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.

source

pub fn bytes(&self) -> &[u8]

The underlying bytes that represent this text.

source

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.

source

pub fn eq(&self, string: &str) -> bool

Compare this exr::Text with a plain &str.

source

pub fn eq_case_insensitive(&self, string: &str) -> bool

Compare this exr::Text with a plain &str ignoring capitalization.

Trait Implementations§

source§

impl Borrow<[u8]> for Text

source§

fn borrow(&self) -> &TextSlice

Immutably borrows from an owned value. Read more
source§

impl Clone for Text

source§

fn clone(&self) -> Text

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Text

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Text

source§

fn default() -> Text

Returns the “default value” for a type. Read more
source§

impl Display for Text

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'s> From<&'s str> for Text

source§

fn from(str: &'s str) -> Self

Panics if the string contains an unsupported character

source§

impl Hash for Text

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Into<String> for Text

source§

fn into(self) -> String

Converts this type into the (usually inferred) input type.
source§

impl Ord for Text

source§

fn cmp(&self, other: &Text) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Text> for str

source§

fn eq(&self, other: &Text) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<str> for Text

source§

fn eq(&self, other: &str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Text

source§

fn eq(&self, other: &Text) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Text

source§

fn partial_cmp(&self, other: &Text) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for Text

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.