OffsetSize

Trait OffsetSize 

Source
pub trait OffsetSize:
    Copy
    + Default
    + Add<Output = Self>
    + AddAssign
    + Mul<Output = Self>
    + Rem<Output = Self>
    + PartialOrd
    + PartialEq
    + Debug
    + 'static {
    const INLINE_THRESHOLD: Self;
    const ZERO: Self;
    const ONE: Self;
    const TWO: Self;

    // Required methods
    fn checked_add(self, rhs: Self) -> Option<Self>;
    fn write_to(self, file: &mut EndianFile) -> Result<()>;
    fn from_usize(val: usize) -> Self;
    fn to_u64(self) -> u64;
}
Expand description

Trait for offset sizes (u32 for TIFF, u64 for BigTIFF).

This trait abstracts over the integer type used for file offsets, allowing the same code to work with both standard TIFF (32-bit offsets) and Big///*TIFF (64-bit offsets).

Required Associated Constants§

Source

const INLINE_THRESHOLD: Self

The inline value threshold (4 for TIFF, 8 for BigTIFF).

Source

const ZERO: Self

Zero value.

Source

const ONE: Self

One value.

Source

const TWO: Self

Two value (for word boundary checks).

Required Methods§

Source

fn checked_add(self, rhs: Self) -> Option<Self>

Checked addition that returns None on overflow.

Source

fn write_to(self, file: &mut EndianFile) -> Result<()>

Write this offset value to an EndianFile.

Source

fn from_usize(val: usize) -> Self

Convert from usize (for lengths).

Source

fn to_u64(self) -> u64

Convert to u64 for comparisons and calculations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl OffsetSize for u32

Source§

const INLINE_THRESHOLD: Self = 4

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn checked_add(self, rhs: Self) -> Option<Self>

Source§

fn write_to(self, file: &mut EndianFile) -> Result<()>

Source§

fn from_usize(val: usize) -> Self

Source§

fn to_u64(self) -> u64

Source§

impl OffsetSize for u64

Source§

const INLINE_THRESHOLD: Self = 8

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn checked_add(self, rhs: Self) -> Option<Self>

Source§

fn write_to(self, file: &mut EndianFile) -> Result<()>

Source§

fn from_usize(val: usize) -> Self

Source§

fn to_u64(self) -> u64

Implementors§