Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 15 variants Byte(Vec<u8>), Ascii(String), Short(Vec<u16>), Long(Vec<u32>), Rational(Vec<(u32, u32)>), SByte(Vec<i8>), Undefined(Vec<u8>), SShort(Vec<i16>), SLong(Vec<i32>), SRational(Vec<(i32, i32)>), Float(Vec<f32>), Double(Vec<f64>), Long8(Vec<u64>), SLong8(Vec<i64>), Ifd8(Vec<u64>),
}
Expand description

The decoded value(s) of one IFD entry, one variant per crate::FieldType.

A TIFF entry always stores a count of values of a single type; even a scalar is a 1-element vector here. On disk the values sit inline in the entry’s value/offset field when they fit, or at a file offset otherwise — a distinction the reader/writer resolve, leaving this type purely the logical value. The BigTIFF 64-bit variants (Long8/SLong8/Ifd8) appear only when the bigtiff feature is enabled.

Variants§

§

Byte(Vec<u8>)

BYTE — unsigned 8-bit integers.

§

Ascii(String)

ASCII — a NUL-terminated 7-bit ASCII string (the terminator is not stored here).

§

Short(Vec<u16>)

SHORT — unsigned 16-bit integers.

§

Long(Vec<u32>)

LONG — unsigned 32-bit integers.

§

Rational(Vec<(u32, u32)>)

RATIONAL — unsigned fractions as (numerator, denominator) pairs.

§

SByte(Vec<i8>)

SBYTE — signed 8-bit integers.

§

Undefined(Vec<u8>)

UNDEFINED — raw bytes whose interpretation depends on the field.

§

SShort(Vec<i16>)

SSHORT — signed 16-bit integers.

§

SLong(Vec<i32>)

SLONG — signed 32-bit integers.

§

SRational(Vec<(i32, i32)>)

SRATIONAL — signed fractions as (numerator, denominator) pairs.

§

Float(Vec<f32>)

FLOAT — IEEE single-precision floats.

§

Double(Vec<f64>)

DOUBLE — IEEE double-precision floats.

§

Long8(Vec<u64>)

LONG8 — BigTIFF 64-bit unsigned integers.

§

SLong8(Vec<i64>)

SLONG8 — BigTIFF 64-bit signed integers.

§

Ifd8(Vec<u64>)

IFD8 — BigTIFF 64-bit IFD offsets.

Implementations§

Source§

impl Value

Source

pub fn field_type(&self) -> FieldType

The field type of this value.

Source

pub fn count(&self) -> usize

The Count of this value: the number of elements, or for ASCII the number of bytes including the terminating NUL.

Source

pub fn byte_len(&self) -> usize

The number of bytes this value occupies on disk (count * type size).

Source

pub fn as_u32(&self) -> Option<u32>

Coerces a single unsigned-integer value (BYTE, SHORT, LONG, or — with bigtiffLONG8/IFD8) to u32.

TIFF readers accept any of these types for an integer field (TIFF 6.0 §2); returns None if the value is not a single unsigned integer or a LONG8/IFD8 exceeds u32::MAX (only possible past the 4 GiB classic-TIFF limit, which an in-memory decode cannot reach anyway).

Source

pub fn as_u32_vec(&self) -> Option<Vec<u32>>

Coerces an array of unsigned integers (BYTE, SHORT, LONG, or — with bigtiffLONG8/IFD8) to Vec<u32>.

Returns None for any other type, or if a LONG8/IFD8 element exceeds u32::MAX. This lets a decoder read BigTIFF StripOffsets/StripByteCounts, which libtiff writes as LONG8.

Source

pub fn encode(&self, order: ByteOrder) -> Vec<u8>

Serialises the value’s elements to bytes in order (without any inline/offset padding).

Source

pub fn decode( ty: FieldType, count: usize, bytes: &[u8], order: ByteOrder, ) -> Result<Value, Error>

Parses count values of ty from bytes (which must hold at least count * ty.size() bytes) in order.

§Errors

Returns Error::InvalidInput if bytes is too short for the declared count.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl PartialEq for Value

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.