pub struct Header { /* private fields */ }Expand description
The parsed 136-byte (0x88) header of a Mario Kart Wii RKG ghost file.
Holds all metadata decoded from the RKGD file header, along with a copy of the raw bytes kept in sync with every setter. The layout is documented at https://wiki.tockdom.com/wiki/RKG_(File_Format)#File_Header.
Implementations§
Source§impl Header
impl Header
Sourcepub fn new_from_path<P: AsRef<Path>>(p: P) -> Result<Self, HeaderError>
pub fn new_from_path<P: AsRef<Path>>(p: P) -> Result<Self, HeaderError>
Parses a Header from an RKG file at the given path.
Only the first 0x88 bytes of the file are read.
§Errors
Returns HeaderError::IoError if the file cannot be opened or read,
and other HeaderError variants if any field fails to parse.
Sourcepub fn new(header_data: &[u8]) -> Result<Self, HeaderError>
pub fn new(header_data: &[u8]) -> Result<Self, HeaderError>
Parses a Header from a 136-byte (0x88) slice.
§Errors
Returns HeaderError::NotCorrectSize if header_data is not exactly
0x88 bytes long. Returns HeaderError::NotRKGD if the first four
bytes are not the RKGD magic. Returns other HeaderError variants
if any individual field fails to parse.
Sourcepub fn verify_mii_crc16(&self) -> bool
pub fn verify_mii_crc16(&self) -> bool
Returns true if the stored Mii CRC-16 matches a computed
checksum of the Mii bytes at offsets 0x3C–0x85.
Sourcepub fn fix_mii_crc16(&mut self)
pub fn fix_mii_crc16(&mut self)
Recomputes the Mii CRC-16 from the current raw header bytes and writes the updated value to both the parsed field and the raw buffer.
Sourcepub fn raw_data_mut(&mut self) -> &mut [u8; 136]
pub fn raw_data_mut(&mut self) -> &mut [u8; 136]
Returns a mutable reference to the raw 136-byte header block.
Sourcepub fn finish_time(&self) -> &InGameTime
pub fn finish_time(&self) -> &InGameTime
Returns the ghost’s recorded finish time.
Sourcepub fn set_finish_time(&mut self, finish_time: InGameTime)
pub fn set_finish_time(&mut self, finish_time: InGameTime)
Sets the finish time and updates the raw data accordingly.
Sourcepub fn set_slot_id(&mut self, slot_id: SlotId)
pub fn set_slot_id(&mut self, slot_id: SlotId)
Sets the course slot and updates the raw data accordingly.
Sourcepub fn set_combo(&mut self, combo: Combo)
pub fn set_combo(&mut self, combo: Combo)
Sets the character/vehicle combo and updates the raw data accordingly.
Sourcepub fn set_date_set(&mut self, date_set: Date)
pub fn set_date_set(&mut self, date_set: Date)
Sets the ghost’s date and updates the raw data accordingly.
Sourcepub fn controller(&self) -> Controller
pub fn controller(&self) -> Controller
Returns the input controller used to record the ghost.
Sourcepub fn set_controller(&mut self, controller: Controller)
pub fn set_controller(&mut self, controller: Controller)
Sets the controller and updates the raw data accordingly.
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Returns whether the ghost’s input data is Yaz1 compressed.
Sourcepub fn transmission_mod(&self) -> TransmissionMod
pub fn transmission_mod(&self) -> TransmissionMod
Returns the Retro Rewind (Pulsar) transmission override active for this ghost.
Sourcepub fn set_transmission_mod(&mut self, transmission_mod: TransmissionMod)
pub fn set_transmission_mod(&mut self, transmission_mod: TransmissionMod)
Sets the transmission mod and updates the raw data accordingly.
Sourcepub fn ghost_type(&self) -> GhostType
pub fn ghost_type(&self) -> GhostType
Returns the ghost type of this ghost.
Sourcepub fn set_ghost_type(&mut self, ghost_type: GhostType)
pub fn set_ghost_type(&mut self, ghost_type: GhostType)
Sets the ghost type and updates the raw data accordingly.
Sourcepub fn is_automatic_drift(&self) -> bool
pub fn is_automatic_drift(&self) -> bool
Returns whether automatic drift was used during the recorded run.
Sourcepub fn set_automatic_drift(&mut self, is_automatic_drift: bool)
pub fn set_automatic_drift(&mut self, is_automatic_drift: bool)
Sets the automatic drift flag and updates the raw data accordingly.
Sourcepub fn decompressed_input_data_length(&self) -> u16
pub fn decompressed_input_data_length(&self) -> u16
Returns the byte length of the input data block after decompression.
Sourcepub fn lap_split_times(&self) -> &[InGameTime]
pub fn lap_split_times(&self) -> &[InGameTime]
Returns a slice of the valid lap split times (length equal to lap_count).
Sourcepub fn lap_split_time(&self, idx: usize) -> Result<InGameTime, HeaderError>
pub fn lap_split_time(&self, idx: usize) -> Result<InGameTime, HeaderError>
Returns the lap split time at the given zero-based idx.
§Errors
Returns HeaderError::LapSplitIndexError if idx is greater than or
equal to lap_count.
Sourcepub fn set_lap_split_time(&mut self, idx: usize, lap_split_time: InGameTime)
pub fn set_lap_split_time(&mut self, idx: usize, lap_split_time: InGameTime)
Sets the lap split time at the given zero-based idx and updates the raw data accordingly.
Does nothing if idx is greater than or equal to lap_count.
Sourcepub fn location(&self) -> &Location
pub fn location(&self) -> &Location
Returns the player’s geographic location when the ghost was set.
Sourcepub fn set_location(&mut self, location: Location)
pub fn set_location(&mut self, location: Location)
Sets the player’s location and updates the raw data accordingly.
When the country is Country::NotSet, the subregion byte is written
as 0xFF (Not Set).
Sourcepub fn mii_mut(&mut self) -> &mut Mii
pub fn mii_mut(&mut self) -> &mut Mii
Returns a mutable reference to the Mii embedded in the ghost header.
Sourcepub fn set_mii(&mut self, mii: Mii)
pub fn set_mii(&mut self, mii: Mii)
Replaces the embedded Mii, updates the raw header bytes at 0x3C–0x85,
and recomputes the Mii CRC-16.
Sourcepub fn mii_crc16(&self) -> u16
pub fn mii_crc16(&self) -> u16
Returns the CRC-16 checksum of the embedded Mii data as stored in the header.
Sourcepub const fn transmission_adjusted(&self) -> Transmission
pub const fn transmission_adjusted(&self) -> Transmission
Returns the transmission of the combo adjusted depending on transmission mod.