pub struct TiffHeader {
pub byte_order: ByteOrder,
pub is_bigtiff: bool,
pub first_ifd_offset: u64,
}Expand description
Parsed TIFF file header.
Contains the essential information needed to begin parsing IFDs:
- Byte order for reading all subsequent values
- Whether this is classic TIFF or BigTIFF (affects entry sizes and offset widths)
- Location of the first IFD
Fields§
§byte_order: ByteOrderByte order for all multi-byte values in the file
is_bigtiff: boolWhether this is a BigTIFF file (64-bit offsets)
first_ifd_offset: u64Offset to the first IFD in the file
Implementations§
Source§impl TiffHeader
impl TiffHeader
Sourcepub fn parse(bytes: &[u8], file_size: u64) -> Result<Self, TiffError>
pub fn parse(bytes: &[u8], file_size: u64) -> Result<Self, TiffError>
Parse a TIFF header from raw bytes.
The input must contain at least 8 bytes for classic TIFF or 16 bytes for BigTIFF. The function first reads enough to determine the format, then validates the rest.
§Arguments
bytes- Raw header bytes (at least 8 bytes, preferably 16 for BigTIFF support)file_size- Total file size (used to validate IFD offset)
§Errors
InvalidMagicif byte order bytes are not II or MMInvalidVersionif version is not 42 or 43InvalidBigTiffOffsetSizeif BigTIFF offset size is not 8FileTooSmallif there aren’t enough bytes for the headerInvalidIfdOffsetif the first IFD offset is outside the file
Sourcepub const fn ifd_entry_size(&self) -> usize
pub const fn ifd_entry_size(&self) -> usize
Size of an IFD entry in bytes.
Classic TIFF: 12 bytes (2 tag + 2 type + 4 count + 4 value/offset) BigTIFF: 20 bytes (2 tag + 2 type + 8 count + 8 value/offset)
Sourcepub const fn ifd_count_size(&self) -> usize
pub const fn ifd_count_size(&self) -> usize
Size of the entry count field at the start of an IFD.
Classic TIFF: 2 bytes (u16) BigTIFF: 8 bytes (u64)
Sourcepub const fn ifd_next_offset_size(&self) -> usize
pub const fn ifd_next_offset_size(&self) -> usize
Size of the next IFD offset field at the end of an IFD.
Classic TIFF: 4 bytes (u32) BigTIFF: 8 bytes (u64)
Sourcepub const fn value_offset_size(&self) -> usize
pub const fn value_offset_size(&self) -> usize
Size of the value/offset field in an IFD entry.
This determines the inline value threshold: Classic TIFF: 4 bytes BigTIFF: 8 bytes
Trait Implementations§
Source§impl Clone for TiffHeader
impl Clone for TiffHeader
Source§fn clone(&self) -> TiffHeader
fn clone(&self) -> TiffHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TiffHeader
impl Debug for TiffHeader
Source§impl PartialEq for TiffHeader
impl PartialEq for TiffHeader
impl Copy for TiffHeader
impl Eq for TiffHeader
impl StructuralPartialEq for TiffHeader
Auto Trait Implementations§
impl Freeze for TiffHeader
impl RefUnwindSafe for TiffHeader
impl Send for TiffHeader
impl Sync for TiffHeader
impl Unpin for TiffHeader
impl UnwindSafe for TiffHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more