Enum exif::Value

source ·
pub enum Value {
Show 13 variants Byte(Vec<u8>), Ascii(Vec<Vec<u8>>), Short(Vec<u16>), Long(Vec<u32>), Rational(Vec<Rational>), SByte(Vec<i8>), Undefined(Vec<u8>, u32), SShort(Vec<i16>), SLong(Vec<i32>), SRational(Vec<SRational>), Float(Vec<f32>), Double(Vec<f64>), Unknown(u16, u32, u32),
}
Expand description

A type and values of a TIFF/Exif field.

Variants§

§

Byte(Vec<u8>)

Vector of 8-bit unsigned integers.

§

Ascii(Vec<Vec<u8>>)

Vector of slices of 8-bit bytes containing 7-bit ASCII characters. The trailing null characters are not included. Note that the 8th bits may present if a non-conforming data is given.

§

Short(Vec<u16>)

Vector of 16-bit unsigned integers.

§

Long(Vec<u32>)

Vector of 32-bit unsigned integers.

§

Rational(Vec<Rational>)

Vector of unsigned rationals. An unsigned rational number is a pair of 32-bit unsigned integers.

§

SByte(Vec<i8>)

Vector of 8-bit signed integers. Unused in the Exif specification.

§

Undefined(Vec<u8>, u32)

Slice of 8-bit bytes.

The second member keeps the offset of the value in the Exif data. The interpretation of the value does not generally depend on the location, but if it does, the offset information helps. When encoding Exif, it is ignored.

§

SShort(Vec<i16>)

Vector of 16-bit signed integers. Unused in the Exif specification.

§

SLong(Vec<i32>)

Vector of 32-bit signed integers.

§

SRational(Vec<SRational>)

Vector of signed rationals. A signed rational number is a pair of 32-bit signed integers.

§

Float(Vec<f32>)

Vector of 32-bit (single precision) floating-point numbers. Unused in the Exif specification.

§

Double(Vec<f64>)

Vector of 64-bit (double precision) floating-point numbers. Unused in the Exif specification.

§

Unknown(u16, u32, u32)

The type is unknown to this implementation. The associated values are the type, the count, and the offset of the “Value Offset” element.

Implementations§

source§

impl Value

source

pub fn display_as(&self, tag: Tag) -> Display<'_>

Returns an object that implements std::fmt::Display for printing a value in a tag-specific format. The tag of the value is specified as the argument.

If you want to display with the unit, use Field::display_value.

§Examples
use exif::{Value, Tag};
let val = Value::Undefined(b"0231".to_vec(), 0);
assert_eq!(val.display_as(Tag::ExifVersion).to_string(), "2.31");
let val = Value::Short(vec![2]);
assert_eq!(val.display_as(Tag::ResolutionUnit).to_string(), "inch");
source

pub fn as_uint(&self) -> Result<&UIntValue, Error>

Returns UIntValue if the value type is unsigned integer (BYTE, SHORT, or LONG). Otherwise exif::Error is returned.

The integer(s) can be obtained by get(&self, index: usize) method on UIntValue, which returns Option<u32>. None is returned if the index is out of bounds.

§Examples
let v = Value::Byte(vec![1u8, 2]);
assert_eq!(v.as_uint()?.get(0), Some(1u32));
assert_eq!(v.as_uint()?.get(2), None);
let v = Value::SLong(vec![1, 2]);
assert!(v.as_uint().is_err());
source

pub fn get_uint(&self, index: usize) -> Option<u32>

Returns the unsigned integer at the given position. None is returned if the value type is not unsigned integer (BYTE, SHORT, or LONG) or the position is out of bounds.

source

pub fn iter_uint(&self) -> Option<UIntIter<'_>>

Returns an iterator over the unsigned integers (BYTE, SHORT, or LONG). The iterator yields u32 regardless of the underlying integer size. The returned iterator implements Iterator and ExactSizeIterator traits. None is returned if the value is not an unsigned integer type.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

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 Value

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

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

§

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

§

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.