#[repr(C)]pub struct HkxHeader {Show 18 fields
pub magic0: i32,
pub magic1: i32,
pub user_tag: i32,
pub file_version: i32,
pub pointer_size: u8,
pub endian: u8,
pub padding_option: u8,
pub base_class: u8,
pub section_count: i32,
pub contents_section_index: i32,
pub contents_section_offset: i32,
pub contents_class_name_section_index: i32,
pub contents_class_name_section_offset: i32,
pub contents_version_string: [u8; 15],
pub contents_version_string_separator: u8,
pub flags: i32,
pub max_predicate: i16,
pub section_offset: i16,
}
Expand description
The 64bytes HKX header contains metadata information about the HKX file.
Fields§
§magic0: i32
First magic number (0x57E0E057
)
magic1: i32
Second magic number (0x10C0C010
)
user_tag: i32
User-defined tag.
file_version: i32
Version of the file.
pointer_size: u8
Size of pointers in bytes (4 or 8)
endian: u8
Endianness of the file (0 for big-endian, 1 for little-endian).
padding_option: u8
Padding option used in the file.
base_class: u8
Base class.
section_count: i32
Number of sections in the HKX file.
§Examples
For SkyrimSE, the bytes are arranged in the following order.
__classnames__
__types__
__data__
contents_section_index: i32
Index of the contents section.
contents_section_offset: i32
Offset of the contents section.
contents_class_name_section_index: i32
Index of the contents class name section.
contents_class_name_section_offset: i32
Offset of the contents class name section.
contents_version_string: [u8; 15]
Version string of the contents.
§Bytes Example
- SkyrimSE
assert_eq!(
*b"hk_2010.2.0-r1\0",
[0x68, 0x6B, 0x5F, 0x32, 0x30, 0x31, 0x30, 0x2E, 0x32, 0x2E, 0x30, 0x2D, 0x72, 0x31, 0x00]
);
contents_version_string_separator: u8
Version string of the contents separator. Always 0xff
flags: i32
Various flags.
max_predicate: i16
Maximum predicate. None is -1 (== 0xFF 0xFF
)
section_offset: i16
Section offset. None is -1 (== 0xFF 0xFF
)
If this number is 16, read 64bytes header plus an extra 16bytes as padding.
Implementations§
Source§impl HkxHeader
impl HkxHeader
Sourcepub const fn endian(&self) -> Endianness
pub const fn endian(&self) -> Endianness
Return Big-endian or little-endian
§Note
Endian must be 0(big)
or 1(little)
.
- If you used the
from_bytes
constructor, it is not a problem because the endian check is already done.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Sourcepub fn parser<'a>() -> impl Parser<&'a [u8], Self, ContextError>
pub fn parser<'a>() -> impl Parser<&'a [u8], Self, ContextError>
Check valid endian & Parse as hkx root header.
Sourcepub fn to_bytes(&self) -> [u8; 64]
pub fn to_bytes(&self) -> [u8; 64]
Convert to bytes.
§Note
If self.endian
is 0, the data is converted to binary data as little endian, otherwise as big endian.
Sourcepub const fn padding_size(&self) -> u32
pub const fn padding_size(&self) -> u32
Sourcepub fn contents_version_string(&self) -> ModalResult<&str>
pub fn contents_version_string(&self) -> ModalResult<&str>
Sourcepub const fn new_skyrim_se() -> Self
pub const fn new_skyrim_se() -> Self
Create a new HkXHeader
instance with default values for Skyrim Special Edition.
§Features
- file version: 8
- pointer size: 8 bytes(64bit)
- endian: 1(little endian)
- base class: 1
- section count: 3(
__classnames__
,__type__
,__data__
) - content section index: 2. In zero-based index,
data
section means the third section. - content class name section offset: 0x4B
- max predicate: -1 (Always
0xff 0xff
in ver. hk2010) - section offset: -1 (Always
0xff 0xff
in ver. hk2010)
Sourcepub const fn new_skyrim_le() -> Self
pub const fn new_skyrim_le() -> Self
Create a new HkXHeader
instance with default values for Skyrim Legendary Edition.
§Features
Almost the same as SkyrimSE, only the pointer_size
is different, 4 instead of 8.
This means that the pointer_size
is 32 bits(4 bytes), for a 32-bit application.
- file version: 8
- pointer size: 4 bytes(32bit)
- endian: 1(little endian)
- base class: 1
- section count: 3(
__classnames__
,__type__
,__data__
) - content section index: 2. In zero-based index,
data
section means the third section. - content class name section offset: 0x4B
- max predicate: -1 (Always
0xff 0xff
in ver. hk2010) - section offset: -1 (Always
0xff 0xff
in ver. hk2010)
Trait Implementations§
impl Eq for HkxHeader
impl StructuralPartialEq for HkxHeader
Auto Trait Implementations§
impl Freeze for HkxHeader
impl RefUnwindSafe for HkxHeader
impl Send for HkxHeader
impl Sync for HkxHeader
impl Unpin for HkxHeader
impl UnwindSafe for HkxHeader
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§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<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