pub struct Field {Show 15 fields
pub key: String,
pub kind: FieldKind,
pub label: String,
pub hint: Option<String>,
pub required: bool,
pub default: Option<Value>,
pub min: Option<i64>,
pub max: Option<i64>,
pub options: Vec<Choice>,
pub format: TextFormat,
pub multiline: bool,
pub kinds: Vec<String>,
pub entry_types: Vec<String>,
pub tags: Vec<String>,
pub multiple: Option<bool>,
}Expand description
A field of a page. Its value comes back in the next call’s input under its key: a string for
text and choice, a bool, an integer, for scenes a list of scene ids (one id or null when
Field::single), and for entity an EntityRef or null (a list of them when Field::multiple).
Hammer checks required, an int’s bounds, a choice’s options, and that an entity’s picks
exist and match its filters before calling, unless the button pressed skips them.
Fields§
§key: String§kind: FieldKind§label: String§hint: Option<String>§required: boolFor text, not blank; for scenes, not empty; for entity, a pick.
default: Option<Value>The initial value; none for the kind’s own: false, min or 0, the first option, “”, or none.
min: Option<i64>§max: Option<i64>§options: Vec<Choice>§format: TextFormat§multiline: bool§kinds: Vec<String>An entity’s kinds of item: scene, note, entry, or event; all four when empty.
entry_types: Vec<String>An entity’s types of entry: person, place, thing, event, or idea; any when empty.
An entity’s tags: an item needs one of them; any item when empty.
multiple: Option<bool>Whether the value is a list; none for the kind’s own, a list for scenes and one item for
entity.
Implementations§
Source§impl Field
impl Field
Sourcepub fn text(key: impl Into<String>, label: impl Into<String>) -> Field
pub fn text(key: impl Into<String>, label: impl Into<String>) -> Field
A text field, plain unless given a Field::format.
pub fn bool(key: impl Into<String>, label: impl Into<String>) -> Field
pub fn int( key: impl Into<String>, label: impl Into<String>, min: Option<i64>, max: Option<i64>, ) -> Field
Sourcepub fn choice(
key: impl Into<String>,
label: impl Into<String>,
options: Vec<Choice>,
) -> Field
pub fn choice( key: impl Into<String>, label: impl Into<String>, options: Vec<Choice>, ) -> Field
A choice of options, at least one.
Sourcepub fn scenes(key: impl Into<String>, label: impl Into<String>) -> Field
pub fn scenes(key: impl Into<String>, label: impl Into<String>) -> Field
Scenes picked from the project’s tree: a list, or one with Field::single.
Sourcepub fn entity(key: impl Into<String>, label: impl Into<String>) -> Field
pub fn entity(key: impl Into<String>, label: impl Into<String>) -> Field
An item of the project picked by name: one EntityRef or null, or a list with Field::multiple. Field::kinds, Field::entry_types, and Field::tags narrow what the picker offers. Hammer shows a default that is gone or does not match as empty.
pub fn hint(self, hint: impl Into<String>) -> Field
pub fn required(self) -> Field
Sourcepub fn default(self, value: impl Into<Value>) -> Field
pub fn default(self, value: impl Into<Value>) -> Field
The initial value, such as "elvish", 8, true, vec![3, 4], or an EntityRef (a Vec of
them for an entity with Field::multiple).
pub fn format(self, format: TextFormat) -> Field
Sourcepub fn kinds(self, kinds: &[&str]) -> Field
pub fn kinds(self, kinds: &[&str]) -> Field
The kinds of item an entity picks: scene, note, entry, or event.
Sourcepub fn entry_types(self, types: &[&str]) -> Field
pub fn entry_types(self, types: &[&str]) -> Field
The types of entry an entity picks, with entry among its kinds: person, place, thing,
event, or idea.
Tags an entity’s item needs one of.