pub struct Field {
    pub tag: Tag,
    pub ifd_num: In,
    pub value: Value,
}
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

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.