#[non_exhaustive]pub enum GameSettingType {
Color(ColorGameSetting),
String(StringGameSetting),
Float(FloatGameSetting),
Int(IntGameSetting),
}Expand description
A typed fallback=Key,Value entry from an openmw.cfg file.
The value is parsed into the most specific type that fits:
- Three comma-separated integers in 0–255 →
Color - A number containing
.that parses asf64→Float - A number that parses as
i64→Int - Anything else →
String
PartialEq comparisons are key-only within the same variant, matching OpenMW’s
last-defined-wins deduplication semantics used by game_settings.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Color(ColorGameSetting)
An RGB colour triple (r,g,b).
String(StringGameSetting)
A plain string value (catch-all for values that aren’t numeric or colour).
Float(FloatGameSetting)
A floating-point value.
Int(IntGameSetting)
A 64-bit integer value.
Implementations§
Source§impl GameSettingType
impl GameSettingType
Sourcepub fn key(&self) -> &String
pub fn key(&self) -> &String
Returns the setting key — the text before the first comma in a fallback=Key,Value entry.
use std::path::PathBuf;
use openmw_config::GameSettingType;
let setting = GameSettingType::try_from(
("iMaxLevel,50".to_string(), PathBuf::default(), &mut String::new())
).unwrap();
assert_eq!(setting.key(), "iMaxLevel");Sourcepub fn float_value(&self) -> Option<f64>
pub fn float_value(&self) -> Option<f64>
The parsed number of a Float setting.
Sourcepub fn color_value(&self) -> Option<(u8, u8, u8)>
pub fn color_value(&self) -> Option<(u8, u8, u8)>
The parsed (r, g, b) triple of a Color setting.
Sourcepub fn meta(&self) -> &GameSettingMeta
pub fn meta(&self) -> &GameSettingMeta
The file that defined the setting and the comment above it.
Sourcepub fn value(&self) -> Cow<'_, str>
pub fn value(&self) -> Cow<'_, str>
Returns the setting value — the text after the first comma in a fallback=Key,Value entry.
use std::path::PathBuf;
use openmw_config::GameSettingType;
let setting = GameSettingType::try_from(
("iMaxLevel,50".to_string(), PathBuf::default(), &mut String::new())
).unwrap();
assert_eq!(setting.value(), "50");Sourcepub fn value_str(&self) -> &str
pub fn value_str(&self) -> &str
Borrowed string view of Self::value.