[][src]Struct exif::Field

pub struct Field {
    pub tag: Tag,
    pub ifd_num: In,
    pub value: Value,
}

A TIFF 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

impl Field[src]

pub fn display_value(&self) -> DisplayValue[src]

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

impl Clone for Field[src]

impl Debug for Field[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.