#[non_exhaustive]pub struct PackSetting {
pub key: String,
pub default: Value,
pub doc: String,
pub stage: Stage,
pub synced: bool,
pub min: Option<f64>,
pub max: Option<f64>,
pub choices: Vec<Value>,
pub text: String,
}Expand description
One setting of a pack, a [[setting]] table of pack.toml.
§Examples
use enshwick::config::Stage;
use enshwick::packs::PackManifest;
let manifest = PackManifest::parse(r#"
id = "you.greeter"
version = "1.0.0"
[[setting]]
key = "greeting"
default = "Welcome"
doc = "What a player who joins reads."
[[setting]]
key = "every"
default = 30
min = 1
stage = "startup"
"#)?;
let schema = manifest.settings_schema().ok_or("no settings")?;
assert_eq!(schema.fields[1].stage, Stage::Startup);
assert_eq!(schema.fields[1].min, Some(1.0));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.key: StringThe key in the settings file, of [a-z0-9_].
default: ValueThe value on first start; its type is the setting’s.
doc: StringWhat it does, for the file’s comments and the Mods screen.
stage: StageWhen a change takes effect: runtime unless said.
synced: boolA startup setting a joined client takes from the server.
min: Option<f64>The smallest number it accepts.
max: Option<f64>The largest number it accepts.
choices: Vec<Value>The values it accepts; empty for any.
text: StringThe key of its translated label in the pack’s texts.toml;
config.<key> unless said.
Trait Implementations§
Source§impl Clone for PackSetting
impl Clone for PackSetting
Source§impl Debug for PackSetting
impl Debug for PackSetting
Source§impl<'de> Deserialize<'de> for PackSetting
impl<'de> Deserialize<'de> for PackSetting
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for PackSetting
Available on crate feature schema only.
impl JsonSchema for PackSetting
Available on crate feature
schema only.Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for PackSetting
impl PartialEq for PackSetting
impl StructuralPartialEq for PackSetting
Auto Trait Implementations§
impl Freeze for PackSetting
impl RefUnwindSafe for PackSetting
impl Send for PackSetting
impl Sync for PackSetting
impl Unpin for PackSetting
impl UnsafeUnpin for PackSetting
impl UnwindSafe for PackSetting
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