Skip to main content

Header

Struct Header 

Source
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

Source

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.

Source

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.

Source

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 0x3C0x85.

Source

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.

Source

pub fn raw_data(&self) -> &[u8; 136]

Returns the raw 136-byte header block.

Source

pub fn raw_data_mut(&mut self) -> &mut [u8; 136]

Returns a mutable reference to the raw 136-byte header block.

Source

pub fn finish_time(&self) -> &InGameTime

Returns the ghost’s recorded finish time.

Source

pub fn set_finish_time(&mut self, finish_time: InGameTime)

Sets the finish time and updates the raw data accordingly.

Source

pub fn slot_id(&self) -> SlotId

Returns the course slot the ghost was recorded on.

Source

pub fn set_slot_id(&mut self, slot_id: SlotId)

Sets the course slot and updates the raw data accordingly.

Source

pub fn combo(&self) -> &Combo

Returns the character and vehicle combo used in the ghost.

Source

pub fn set_combo(&mut self, combo: Combo)

Sets the character/vehicle combo and updates the raw data accordingly.

Source

pub fn date_set(&self) -> &Date

Returns the date the ghost was set.

Source

pub fn set_date_set(&mut self, date_set: Date)

Sets the ghost’s date and updates the raw data accordingly.

Source

pub fn controller(&self) -> Controller

Returns the input controller used to record the ghost.

Source

pub fn set_controller(&mut self, controller: Controller)

Sets the controller and updates the raw data accordingly.

Source

pub fn is_compressed(&self) -> bool

Returns whether the ghost’s input data is Yaz1 compressed.

Source

pub fn transmission_mod(&self) -> TransmissionMod

Returns the Retro Rewind (Pulsar) transmission override active for this ghost.

Source

pub fn set_transmission_mod(&mut self, transmission_mod: TransmissionMod)

Sets the transmission mod and updates the raw data accordingly.

Source

pub fn ghost_type(&self) -> GhostType

Returns the ghost type of this ghost.

Source

pub fn set_ghost_type(&mut self, ghost_type: GhostType)

Sets the ghost type and updates the raw data accordingly.

Source

pub fn is_automatic_drift(&self) -> bool

Returns whether automatic drift was used during the recorded run.

Source

pub fn set_automatic_drift(&mut self, is_automatic_drift: bool)

Sets the automatic drift flag and updates the raw data accordingly.

Source

pub fn decompressed_input_data_length(&self) -> u16

Returns the byte length of the input data block after decompression.

Source

pub fn lap_count(&self) -> u8

Returns the number of laps recorded in this ghost.

Source

pub fn lap_split_times(&self) -> &[InGameTime]

Returns a slice of the valid lap split times (length equal to lap_count).

Source

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.

Source

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.

Source

pub fn location(&self) -> &Location

Returns the player’s geographic location when the ghost was set.

Source

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).

Source

pub fn mii(&self) -> &Mii

Returns a reference to the Mii embedded in the ghost header.

Source

pub fn mii_mut(&mut self) -> &mut Mii

Returns a mutable reference to the Mii embedded in the ghost header.

Source

pub fn set_mii(&mut self, mii: Mii)

Replaces the embedded Mii, updates the raw header bytes at 0x3C0x85, and recomputes the Mii CRC-16.

Source

pub fn mii_crc16(&self) -> u16

Returns the CRC-16 checksum of the embedded Mii data as stored in the header.

Source

pub const fn transmission_adjusted(&self) -> Transmission

Returns the transmission of the combo adjusted depending on transmission mod.

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.