pub struct FormValues { /* private fields */ }Expand description
What a form holds, one FormValue per key: a submission its schema
read, or a stored record as its record form spells it.
A record form’s hydrate writes one and its
parse reads one, as an ActionInput’s parse
does. Each key holds the shape its control posts: Text for a scalar
control, a List for a multiple choice, and Rows for a
repeater.
use tablo_core::FormValues;
let mut values = FormValues::new();
values.insert("title", "Hello");
values.insert("tags", vec!["rust".to_string(), "web".to_string()]);
assert_eq!(values.text("title"), Some("Hello"));
assert_eq!(values.list("tags").map(<[String]>::len), Some(2));
assert_eq!(values.text("tags"), None);Implementations§
Source§impl FormValues
impl FormValues
Sourcepub fn text(&self, key: &str) -> Option<&str>
pub fn text(&self, key: &str) -> Option<&str>
The text key holds; None when it holds none, or a list or rows.
Sourcepub fn list(&self, key: &str) -> Option<&[String]>
pub fn list(&self, key: &str) -> Option<&[String]>
The list key holds; None when it holds none, or text or rows.
Sourcepub fn rows(&self, key: &str) -> Option<&[FormValues]>
pub fn rows(&self, key: &str) -> Option<&[FormValues]>
The rows key holds; None when it holds none, or text or a list.
Trait Implementations§
Source§impl Clone for FormValues
impl Clone for FormValues
Source§impl Debug for FormValues
impl Debug for FormValues
Source§impl Default for FormValues
impl Default for FormValues
impl Eq for FormValues
Source§impl<K: Into<String>, V: Into<FormValue>> Extend<(K, V)> for FormValues
Sets each key in turn: a later value replaces an earlier one.
impl<K: Into<String>, V: Into<FormValue>> Extend<(K, V)> for FormValues
Sets each key in turn: a later value replaces an earlier one.
Source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<K: Into<String>, V: Into<FormValue>> FromIterator<(K, V)> for FormValues
impl<K: Into<String>, V: Into<FormValue>> FromIterator<(K, V)> for FormValues
Source§impl IntoIterator for FormValues
impl IntoIterator for FormValues
Source§impl PartialEq for FormValues
impl PartialEq for FormValues
impl StructuralPartialEq for FormValues
Auto Trait Implementations§
impl Freeze for FormValues
impl RefUnwindSafe for FormValues
impl Send for FormValues
impl Sync for FormValues
impl Unpin for FormValues
impl UnsafeUnpin for FormValues
impl UnwindSafe for FormValues
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.