Struct Ifd

Source
pub struct Ifd { /* private fields */ }
Expand description

A structure that holds both an IFD and all the values pointed at by its entries.

An image file directory (IFD) contains information about the image, as well as pointers to the actual image data (both stored as entries).

In a TIFF file, an IFD may point to another IFD with its last 4 bytes. To abstract the user of this crate from the position of each structure in the file, this link between Ifds is represented by an IfdChain. Because any IFD could technically point to a next one, in most functions that one would expect to input an Ifd, its parameters actually ask for an IfdChain.

One can easily create an IfdChain of a single Ifd calling the method single() on that Ifd.

Implementations§

Source§

impl Ifd

Source

pub fn new() -> Ifd

Creates a new empty Ifd.

Note that an empty IFD is prohibited by the TIFF specification. As such, it is not possible to directly use the resulting Ifd alone in the creation of a TIFF file.

However, one can chain this function with methods such as with_entry(FieldTag, FieldValues) in order to build a valid Ifd.

Source

pub fn with_entry<T: FieldValues + 'static>( self, tag: FieldTag, value: T, ) -> Self

Returns the same Ifd, but adding the given pair of Tag and Values.

Because it returns Self, it is possible to chain this method.

§Examples

Creating a TiffFile with some arbitrary entries.

Note that the order in which entries are added is irrelevant. Internally, the Ifd will automatically arrange them by ascending order of tags, as specified by the TIFF specification.

#[macro_use]
extern crate tiff_encoder;
use tiff_encoder::prelude::*;

let ifd = Ifd::new()
    .with_entry(0x0000, BYTE![0])
    .with_entry(0x00FF, LONG![500])
    .with_entry(0xA01F, SHORT![50, 2, 0, 3])
    .with_entry(0x0005, ASCII!["Hello TIFF!"])
    .with_entry(0x0100, UNDEFINED![0x42, 0x42, 0x42, 0x42]);
§Panics

In order to protect the user of this crate, trying to add a value to an already existing entry with this method is considered a mistake and will panic.

Other functions that insert members to the Ifd will have an “Entries” section, where they’ll specify which entries are inserted.

Source

pub fn with_entries<C: IntoIterator<Item = (FieldTag, Box<dyn FieldValues>)>>( self, entries: C, ) -> Self

Returns the same Ifd, after adding the specified pairs of Tags and Values.

Because it returns Self, it is possible to chain this method.

§Panics

If the inserted entries already exist, this function will panic.

Source

pub fn with_subifds(self, subifds: Vec<IfdChain>) -> Self

Returns the same Ifd, but adding the given subifds.

Because it returns Self, it is possible to chain this method.

§Entries

Using this method will automatically insert the entry 0x014A (tag::SubIFDs).

§Panics

If the inserted entries already exist, this function will panic.

Source

pub fn single(self) -> IfdChain

Returns an IfdChain containing solely this Ifd.

In other words, it marks this Ifd as the single element of its chain.

Auto Trait Implementations§

§

impl Freeze for Ifd

§

impl !RefUnwindSafe for Ifd

§

impl !Send for Ifd

§

impl !Sync for Ifd

§

impl Unpin for Ifd

§

impl !UnwindSafe for Ifd

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.