#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
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 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");Trait Implementations§
Source§impl Clone for GameSettingType
impl Clone for GameSettingType
Source§fn clone(&self) -> GameSettingType
fn clone(&self) -> GameSettingType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GameSettingType
impl Debug for GameSettingType
Source§impl Display for GameSettingType
impl Display for GameSettingType
Source§impl PartialEq<&str> for GameSettingType
impl PartialEq<&str> for GameSettingType
Source§impl PartialEq for GameSettingType
impl PartialEq for GameSettingType
impl Eq for GameSettingType
Auto Trait Implementations§
impl Freeze for GameSettingType
impl RefUnwindSafe for GameSettingType
impl Send for GameSettingType
impl Sync for GameSettingType
impl Unpin for GameSettingType
impl UnsafeUnpin for GameSettingType
impl UnwindSafe for GameSettingType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more