Skip to main content

DirectoryEncoder

Struct DirectoryEncoder 

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

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§

Source§

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

Source

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

Write a single ifd tag.

Source

pub 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).

Source

pub 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.

Source

pub 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).

Source

pub 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.

Source

pub 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.

Source

pub 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.

Source

pub 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.

Source

pub 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.

Source

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

Write out the ifd directory itself.

Source

pub 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§

Source§

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, W, K> Freeze for DirectoryEncoder<'a, W, K>

§

impl<'a, W, K> RefUnwindSafe for DirectoryEncoder<'a, W, K>

§

impl<'a, W, K> Send for DirectoryEncoder<'a, W, K>
where K: Send, W: Send,

§

impl<'a, W, K> Sync for DirectoryEncoder<'a, W, K>
where K: Sync, W: Sync,

§

impl<'a, W, K> Unpin for DirectoryEncoder<'a, W, K>
where K: Unpin,

§

impl<'a, W, K> UnsafeUnpin for DirectoryEncoder<'a, W, K>

§

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

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.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,