53 lines
1.3 KiB
Rust
53 lines
1.3 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
|
|
pub enum CanonicalValue {
|
|
Bool(bool),
|
|
Integer(i64),
|
|
Decimal(String),
|
|
Enum(String),
|
|
Text(String),
|
|
StringList(Vec<String>),
|
|
KeyBinding(String),
|
|
ExternalRaw(String),
|
|
}
|
|
|
|
impl CanonicalValue {
|
|
pub(crate) fn type_name(&self) -> &'static str {
|
|
match self {
|
|
Self::Bool(_) => "bool",
|
|
Self::Integer(_) => "integer",
|
|
Self::Decimal(_) => "decimal",
|
|
Self::Enum(_) => "enum",
|
|
Self::Text(_) => "text",
|
|
Self::StringList(_) => "string_list",
|
|
Self::KeyBinding(_) => "key_binding",
|
|
Self::ExternalRaw(_) => "external_raw",
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum GameOptionKind {
|
|
Vanilla,
|
|
External,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct StoredOption {
|
|
pub(crate) option_id: String,
|
|
pub(crate) kind: GameOptionKind,
|
|
pub(crate) raw_key: Option<String>,
|
|
pub(crate) value: Option<CanonicalValue>,
|
|
pub(crate) seeded: bool,
|
|
pub(crate) revision: u64,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct StoredPreference {
|
|
pub(crate) enabled: bool,
|
|
pub(crate) revision: u64,
|
|
}
|