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>
impl<'a, W: 'a + Write + Seek, K: TiffKind> DirectoryEncoder<'a, W, K>
Sourcepub fn write_tag<T: TiffValue>(&mut self, tag: Tag, value: T) -> TiffResult<()>
pub fn write_tag<T: TiffValue>(&mut self, tag: Tag, value: T) -> TiffResult<()>
Write a single ifd tag.
Sourcepub fn write_tag_buf(&mut self, tag: Tag, value: &ValueBuffer) -> TiffResult<()>
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).
Sourcepub fn write_data<T: TiffValue>(&mut self, value: T) -> TiffResult<u64>
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.
Sourcepub fn write_data_buf(&mut self, value: &ValueBuffer) -> TiffResult<u64>
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).
Sourcepub fn write_entry<T: TiffValue>(&mut self, value: T) -> TiffResult<Entry>
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.
Sourcepub fn write_entry_buf(&mut self, value: &ValueBuffer) -> TiffResult<Entry>
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.
Sourcepub fn write_entry_bytes(&mut self, ty: Type, data: &[u8]) -> TiffResult<Entry>
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.
Sourcepub fn extend_from(&mut self, dir: &Directory)
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.
Sourcepub fn set_parent(&mut self, offset: &DirectoryOffset<K>)
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.
Sourcepub fn finish(self) -> TiffResult<()>
pub fn finish(self) -> TiffResult<()>
Write out the ifd directory itself.
Sourcepub fn finish_with_offsets(self) -> TiffResult<DirectoryOffset<K>>
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.