Expand description
A TIFF/Exif field.
Fields
tag: Tag
The tag of this field.
ifd_num: In
The index of the IFD to which this field belongs.
value: Value
The value of this field.
Implementations
sourceimpl Field
impl Field
sourcepub fn display_value(&self) -> DisplayValue<'_>
pub fn display_value(&self) -> DisplayValue<'_>
Returns an object that implements std::fmt::Display
for
printing the value of this field in a tag-specific format.
To print the value with the unit, call with_unit
method on the
returned object. It takes a parameter, which is either ()
,
&Field
, or &Exif
, that provides the unit information.
If the unit does not depend on another field, ()
can be used.
Otherwise, &Field
or &Exif
should be used.
Examples
use exif::{Field, In, Tag, Value};
let xres = Field {
tag: Tag::XResolution,
ifd_num: In::PRIMARY,
value: Value::Rational(vec![(72, 1).into()]),
};
let resunit = Field {
tag: Tag::ResolutionUnit,
ifd_num: In::PRIMARY,
value: Value::Short(vec![3]),
};
assert_eq!(xres.display_value().to_string(), "72");
assert_eq!(resunit.display_value().to_string(), "cm");
// The unit of XResolution is indicated by ResolutionUnit.
assert_eq!(xres.display_value().with_unit(&resunit).to_string(),
"72 pixels per cm");
// If ResolutionUnit is not given, the default value is used.
assert_eq!(xres.display_value().with_unit(()).to_string(),
"72 pixels per inch");
assert_eq!(xres.display_value().with_unit(&xres).to_string(),
"72 pixels per inch");
let flen = Field {
tag: Tag::FocalLengthIn35mmFilm,
ifd_num: In::PRIMARY,
value: Value::Short(vec![24]),
};
// The unit of the focal length is always mm, so the argument
// has nothing to do with the result.
assert_eq!(flen.display_value().with_unit(()).to_string(),
"24 mm");
assert_eq!(flen.display_value().with_unit(&resunit).to_string(),
"24 mm");
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnwindSafe for Field
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more