pub struct CommonHeader<'a> { /* private fields */ }Expand description
View type for the NSIS common header.
The common header sits at the start of the decompressed header block. It provides flags, block descriptors (which give offsets into the rest of the decompressed data), callback entry indices, and install configuration.
Implementations§
Source§impl<'a> CommonHeader<'a>
impl<'a> CommonHeader<'a>
Sourcepub fn parse(
data: &'a [u8],
version_hint: NsisVersionHint,
) -> Result<Self, Error>
pub fn parse( data: &'a [u8], version_hint: NsisVersionHint, ) -> Result<Self, Error>
Parses the common header from the start of the decompressed header data.
The version_hint guides layout selection. If Unknown, the parser
tries the standard layout and validates block headers.
§Errors
Error::TooShortifdatais smaller than the minimum header sizeError::InvalidBlockOffsetif any block header points outsidedata
Sourcepub fn block(&self, bt: BlockType) -> &BlockHeader<'a>
pub fn block(&self, bt: BlockType) -> &BlockHeader<'a>
Returns the block header for the given block type.
The BlockType enum discriminants are always within 0..BLOCKS_NUM,
so this lookup never returns None for a well-formed BlockType;
the .first() fallback is purely defensive.
Sourcepub fn blocks(&self) -> &[BlockHeader<'a>; 8]
pub fn blocks(&self) -> &[BlockHeader<'a>; 8]
Returns all 8 block headers.
Sourcepub fn version(&self) -> NsisVersionHint
pub fn version(&self) -> NsisVersionHint
Returns the detected (or hinted) NSIS version.
Sourcepub fn install_reg_rootkey(&self) -> i32
pub fn install_reg_rootkey(&self) -> i32
Returns the install registry root key.
Located after the block headers at offset 4 + 8*8 = 68.
Sourcepub fn langtable_size(&self) -> i32
pub fn langtable_size(&self) -> i32
Returns the language table entry size.
This field determines the size of each entry in the language table block. Located at a version-dependent offset after the color fields.
Sourcepub fn code_on_init(&self) -> i32
pub fn code_on_init(&self) -> i32
Returns the callback entry index for .onInit (-1 if unused).
Sourcepub fn code_on_inst_success(&self) -> i32
pub fn code_on_inst_success(&self) -> i32
Returns the callback entry index for .onInstSuccess (-1 if unused).
Sourcepub fn code_on_inst_failed(&self) -> i32
pub fn code_on_inst_failed(&self) -> i32
Returns the callback entry index for .onInstFailed (-1 if unused).
Sourcepub fn code_on_user_abort(&self) -> i32
pub fn code_on_user_abort(&self) -> i32
Returns the callback entry index for .onUserAbort (-1 if unused).
Sourcepub fn code_on_gui_init(&self) -> i32
pub fn code_on_gui_init(&self) -> i32
Returns the callback entry index for .onGUIInit (-1 if unused).
Sourcepub fn code_on_gui_end(&self) -> i32
pub fn code_on_gui_end(&self) -> i32
Returns the callback entry index for .onGUIEnd (-1 if unused).
Sourcepub fn code_on_mouse_over_section(&self) -> i32
pub fn code_on_mouse_over_section(&self) -> i32
Returns the callback entry index for .onMouseOverSection (-1 if unused).
Sourcepub fn code_on_verify_inst_dir(&self) -> i32
pub fn code_on_verify_inst_dir(&self) -> i32
Returns the callback entry index for .onVerifyInstDir (-1 if unused).
Sourcepub fn code_on_sel_change(&self) -> i32
pub fn code_on_sel_change(&self) -> i32
Returns the callback entry index for .onSelChange (-1 if unused).
Sourcepub fn code_on_reboot_failed(&self) -> i32
pub fn code_on_reboot_failed(&self) -> i32
Returns the callback entry index for .onRebootFailed (-1 if unused).
Sourcepub fn block_data(
&self,
bt: BlockType,
header_data: &'a [u8],
) -> Result<&'a [u8], Error>
pub fn block_data( &self, bt: BlockType, header_data: &'a [u8], ) -> Result<&'a [u8], Error>
Returns a slice of the decompressed header data for the given block type.
The returned slice starts at the block’s offset and contains num items
(the interpretation of “num” depends on the block type).
§Errors
Returns Error::InvalidBlockOffset if the block offset or computed
end is beyond the available data.
Sourcepub fn is_auto_close(&self) -> bool
pub fn is_auto_close(&self) -> bool
Returns true if the installer auto-closes after installation.