[][src]Struct tiff_encoder::ifd::Ifd

pub struct Ifd { /* fields omitted */ }

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.

Methods

impl Ifd[src]

pub fn new() -> Ifd[src]

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.

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

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.

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

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.

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

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.

pub fn single(self) -> IfdChain[src]

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 !Send for Ifd

impl !Sync for Ifd

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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