Skip to main content

Header

Struct Header 

Source
pub struct Header {
    pub format: Option<Format>,
    pub type_size: u32,
    pub pixel_width: u32,
    pub pixel_height: u32,
    pub pixel_depth: u32,
    pub layer_count: u32,
    pub face_count: u32,
    pub level_count: u32,
    pub supercompression_scheme: Option<SupercompressionScheme>,
    pub index: Index,
}
Expand description

Container-level metadata (dimensions, format, layout) from the 80-byte KTX2 file header.

Fields§

§format: Option<Format>

Vulkan VkFormat enum value. None means VK_FORMAT_UNDEFINED, used for supercompressed universal formats (e.g. Basis Universal) where the actual format is determined at transcode time.

§type_size: u32

Size in bytes of the data type used for GPU upload, for endian conversion on big-endian systems (all image data in KTX2 is little-endian).

Must be 1 when format is None (VK_FORMAT_UNDEFINED) or for block-compressed formats (_BLOCK suffix). For packed formats (_PACKxx), equals the byte size of the packed unit xx / 8 (e.g. 4 for _PACK32). For unpacked formats, equals the byte size of a single component (e.g. 2 for R16G16B16_UNORM). For combined depth/stencil: 2 for D16_UNORM_S8_UINT, 4 for all others.

§pixel_width: u32

Texture width in texels. Always non-zero.

§pixel_height: u32

Texture height in texels. 0 for 1D textures.

§pixel_depth: u32

Texture depth in texels. 0 for non-3D textures.

§layer_count: u32

Number of array layers. 0 means a non-array texture (1 implicit layer). Use layer_count.max(1) when allocating storage.

§face_count: u32

Number of cubemap faces. 6 for cubemaps, 1 otherwise.

§level_count: u32

Number of mip levels. 0 means the full mip chain should be generated from level 0 by the application if needed. Use level_count.max(1) when iterating stored levels.

§supercompression_scheme: Option<SupercompressionScheme>

Compression applied to mip level data. None means uncompressed. When set, each Level::data must be decompressed before use.

§index: Index

Raw byte offsets/lengths for the DFD, KVD, and SGD sections. For most use cases, prefer Reader::dfd_blocks, Reader::key_value_data, and Reader::supercompression_global_data instead.

Implementations§

Source§

impl Header

Source

pub const LENGTH: usize = 80

Size of the KTX2 header in bytes (12-byte magic + 68-byte fields).

Source

pub fn from_bytes(data: &[u8; 80]) -> Result<Self, ParseError>

Decode a header from exactly 80 bytes. Validates the magic bytes and rejects zero pixel_width or zero face_count.

Source

pub fn as_bytes(&self) -> [u8; 80]

Serialize this header back to 80 bytes (including magic).

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Header

Source§

impl Debug for Header

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Header

Source§

impl PartialEq for Header

Source§

fn eq(&self, other: &Header) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.