pub enum Value {
}
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
impl Value
sourcepub fn display_as(&self, tag: Tag) -> Display<'_>
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");
sourcepub fn as_uint(&self) -> Result<&UIntValue, Error>
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());
sourcepub fn get_uint(&self, index: usize) -> Option<u32>
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.
sourcepub fn iter_uint(&self) -> Option<UIntIter<'_>>
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.