Struct DirectoryEncoder

pub struct DirectoryEncoder<'a, W: 'a + Write + Seek, K: TiffKind> { /* private fields */ }

Low level interface to encode ifd directories.

You should call finish on this when you are finished with it. Encoding can silently fail while this is dropping.

Implementations

impl<'a, W: 'a + Write + Seek, K: TiffKind> DirectoryEncoder<'a, W, K>

fn write_tag<T: TiffValue>(&mut self, tag: Tag, value: T) -> TiffResult<()>

Write a single ifd tag.

fn write_tag_buf(&mut self, tag: Tag, value: &ValueBuffer) -> TiffResult<()>

Write a tag-value pair with prepared byte data.

Note that the library will not attempt to verify that the data type or the count of the buffered value is permissible for the given tag. The data will be associated with the tag exactly as-is.

An error is returned if the byte order of the presented value does not match the byte order of the underlying file (i.e. the native byte order).

fn write_data<T: TiffValue>(&mut self, value: T) -> TiffResult<u64>

Write some data to the tiff file, the offset of the data is returned.

This could be used to write tiff strips. All of the data will be written into the file as a slice of bytes. It can not be used as an entry in a directory directly, where very short values are instead represented in the offset field directly. Use Self::write_entry instead.

fn write_data_buf(&mut self, value: &ValueBuffer) -> TiffResult<u64>

Write some data directly to the tiff file, the offset of the data is returned.

All of the data will be written into the file as a slice of bytes. It can not be used as an entry in a directory directly, where very short values are instead represented in the offset field directly. Use Self::write_entry_buf instead.

An error is returned if the byte order of the presented value does not match the byte order of the underlying file (i.e. the native byte order).

fn write_entry<T: TiffValue>(&mut self, value: T) -> TiffResult<Entry>

Write a directory value into the file.

Returns an Entry. If the value is short enough it will not be written in the file but stored in the entry's offset field.

fn write_entry_buf(&mut self, value: &ValueBuffer) -> TiffResult<Entry>

Write a directory value into the file.

An error is returned if the byte order of the presented value does not match the byte order of the underlying file (i.e. the native byte order).

Returns an Entry. If the value is short enough it will not be written in the file but stored in the entry's offset field.

fn write_entry_bytes(&mut self, ty: Type, data: &[u8]) -> TiffResult<Entry>

Write a directory entry by its byte data.

The data must be pre-formatted to the byte order expected by the file.

Returns an Entry. If the value is short enough it will not be written in the file but stored in the entry's offset field.

fn extend_from(&mut self, dir: &Directory)

Insert previously written key-value entries.

It is the caller's responsibility to ensure that the data referred to by the entries is actually (or will be) written to the file. Note that small values are necessarily inline in the entry, the size limit depends on the Tiff kind. So do not confuse a directory from a BigTiff in a standard tiff or the other way around.

fn set_parent(&mut self, offset: &DirectoryOffset<K>)

Define the parent directory.

Each directory has an offset based link to its successor, forming a linked list in the file. The encoder writes its own offset into the parent's field when Self::finish is called or it is dropped. This redefines the parent. An offset representation of the parent must be acquired by finishing it with Self::finish_with_offsets.

fn finish(self) -> TiffResult<()>

Write out the ifd directory itself.

fn finish_with_offsets(self) -> TiffResult<DirectoryOffset<K>>

Write the IFD to the file and return the offset it is written to.

The offset can be used as the value, or as part of a list of values, in the entry of another directory. If you're constructing the entry directly you'll want to use an appropriate type variant for this such as Type::IFD.

Trait Implementations

impl<'a, W: Write + Seek, K: TiffKind> Drop for DirectoryEncoder<'a, W, K>

fn drop(&mut self)

Auto Trait Implementations

impl<'a, W, K> !UnwindSafe for DirectoryEncoder<'a, W, K>

impl<'a, W, K> Freeze for DirectoryEncoder<'a, W, K> where &'a mut TiffWriter<W>: Freeze, PhantomData<K>: Freeze,

impl<'a, W, K> RefUnwindSafe for DirectoryEncoder<'a, W, K> where &'a mut TiffWriter<W>: RefUnwindSafe, PhantomData<K>: RefUnwindSafe,

impl<'a, W, K> Send for DirectoryEncoder<'a, W, K> where &'a mut TiffWriter<W>: Send, PhantomData<K>: Send,

impl<'a, W, K> Sync for DirectoryEncoder<'a, W, K> where &'a mut TiffWriter<W>: Sync, PhantomData<K>: Sync,

impl<'a, W, K> Unpin for DirectoryEncoder<'a, W, K> where &'a mut TiffWriter<W>: Unpin, PhantomData<K>: Unpin,

impl<'a, W, K> UnsafeUnpin for DirectoryEncoder<'a, W, K> where &'a mut TiffWriter<W>: UnsafeUnpin, PhantomData<K>: UnsafeUnpin,

Blanket Implementations

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DirectoryEncoder<'a, W, K> where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DirectoryEncoder<'a, W, K> where ST: ?Sized, DT: ?Sized,

impl<T> Any for DirectoryEncoder<'a, W, K> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for DirectoryEncoder<'a, W, K> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for DirectoryEncoder<'a, W, K> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for DirectoryEncoder<'a, W, K>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Read<Exclusive, BecauseExclusive> for DirectoryEncoder<'a, W, K> where T: ?Sized,

impl<T, U> Into<U> for DirectoryEncoder<'a, W, K> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for DirectoryEncoder<'a, W, K> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for DirectoryEncoder<'a, W, K> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>