Skip to main content

decode

Function decode 

Source
pub fn decode(code: &str) -> Result<CheatPatch, CheatError>
Expand description

Decode code as a Game Genie code, falling back to Pro Action Replay only when code doesn’t match the Game Genie shape at all.

The two formats’ valid shapes never overlap (9 characters with a dash vs. exactly 8 hex digits), so this dispatch is unambiguous. Only CheatError::UnrecognizedFormat falls through to the Pro Action Replay decoder — a Game Genie–shaped code with a genuinely invalid character (e.g. C282-070G) returns that specific CheatError::InvalidCharacter instead of a misleading “wrong format” from a decoder that was never going to match its shape either.

§Errors

Returns the CheatError from whichever format code’s length suggests; if neither format recognizes the shape at all, returns CheatError::UnrecognizedFormat.