Make Error and GameType enums non-exhaustive

So that it's not a breaking change to add more variants in the future.
This commit is contained in:
Oliver Hamlet
2025-01-29 18:38:24 +00:00
parent 9e2aa0cf9c
commit a8f9a5734a
4 changed files with 7 additions and 2 deletions
+4
View File
@@ -37,6 +37,10 @@ pub static LCI_ERROR_POISONED_THREAD_LOCK: c_int = -6;
#[no_mangle]
pub static LCI_ERROR_TEXT_ENCODE_FAIL: c_int = -7;
/// The library encountered an error that should not have been possible to encounter.
#[no_mangle]
pub static LCI_ERROR_INTERNAL_LOGIC_ERROR: c_int = -8;
/// Game code for The Elder Scrolls III: Morrowind.
#[no_mangle]
pub static LCI_GAME_MORROWIND: c_int = 8;
+1
View File
@@ -28,6 +28,7 @@ fn map_error(err: &Error) -> c_int {
Error::ParsingError(_, _) => LCI_ERROR_PARSING_ERROR,
Error::PeParsingError(_, _) => LCI_ERROR_PE_PARSING_ERROR,
Error::IoError(_, _) => LCI_ERROR_IO_ERROR,
_ => LCI_ERROR_INTERNAL_LOGIC_ERROR,
}
}
+1
View File
@@ -9,6 +9,7 @@ use nom::error::ErrorKind;
use nom::Err;
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
ParsingIncomplete(MoreDataNeeded),
// The string is the input that was not parsed.
+1 -2
View File
@@ -22,9 +22,8 @@ use function::Function;
type ParsingResult<'a, T> = IResult<&'a str, T, ParsingError<&'a str>>;
// GameType variants must not change order, as their integer values are used as
// constants in the C API.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum GameType {
Oblivion,
Skyrim,