pub struct Form {
pub verdict: Verdict,
pub fields: Vec<Field>,
pub selected: usize,
pub error: Option<String>,
}Fields§
§verdict: Verdict§fields: Vec<Field>§selected: usizeThe selected row of Form::rows.
error: Option<String>The last local or human::submit error.
Implementations§
Source§impl Form
impl Form
Sourcepub fn from_spec(verdict: Verdict, spec: &Specification) -> Self
pub fn from_spec(verdict: Verdict, spec: &Specification) -> Self
Open the form using an already validated specification.
Sourcepub fn new(verdict: Verdict, schema: Option<&Value>) -> Result<Self, String>
pub fn new(verdict: Verdict, schema: Option<&Value>) -> Result<Self, String>
Parse an externally supplied JSON schema into a form at the input boundary.
Sourcepub fn submission(&self) -> Result<Submission, String>
pub fn submission(&self) -> Result<Submission, String>
The typed answer after validating the form’s fields.
Sourcepub fn result(&self) -> Result<Value, String>
pub fn result(&self) -> Result<Value, String>
The complete result as JSON: owner fields plus the chosen verdict.
Sourcepub fn add(&mut self, index: usize)
pub fn add(&mut self, index: usize)
Add an empty item to the list of field index: an empty text to a list of strings, an
empty group to a list of groups, which the selection moves into.
Sourcepub fn remove(&mut self, index: usize, item: usize)
pub fn remove(&mut self, index: usize, item: usize)
Remove item item of the list of field index; one empty item always stays to type in.
Sourcepub fn remove_selected(&mut self)
pub fn remove_selected(&mut self)
Remove the group the selection is in.
Sourcepub fn paste(&mut self, text: &str)
pub fn paste(&mut self, text: &str)
Bounded paste follows the existing Human result limit, without splitting UTF-8.
Sourcepub fn inline_key(&mut self, key: Key, modified: bool)
pub fn inline_key(&mut self, key: Key, modified: bool)
A key typed into the form. Enter never submits: on + Add it adds a group, in a list
it starts the next item. Keys with Control or Alt are not the form’s.