Struct exif::Field

source ·
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§

source§

impl Field

source

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§

source§

impl Clone for Field

source§

fn clone(&self) -> Field

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 Field

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Field

§

impl RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnwindSafe for Field

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.