mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
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:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user