pub enum BoundInput {
Value,
Checkbox,
Radio,
Unknown,
File,
SelectMultiple,
}Expand description
What a bind={field} on an element actually WRITES — the one place the whole language
decides, so no two walks can disagree about a checkbox.
An <input type="text"> holds its state in value, a string. An <input type="checkbox">
(or type="radio") holds its state in checked, a PRESENCE — and not in the checked
ATTRIBUTE either, which is defaultChecked. Writing a checkbox’s state as a value renders
value="true" and draws the box UNCHECKED while the page believes it is checked, which is
worse than not supporting bind on a checkbox at all: the author has been told their
binding was understood.
Variants§
Value
value — a text/number/date input, a <textarea>, a <select>.
Checkbox
checked, and a click FLIPS it — a checkbox.
Radio
checked, and a click SELECTS it — a radio. Split from BoundInput::Checkbox because
the two differ exactly where it matters: clicking a chosen radio leaves it chosen, and a
lowering that flipped it would let a second click deselect it, which no radio group has
ever done.
Unknown
The element’s type is computed, so which of the two this is cannot be known until the
page runs. Refused rather than guessed: guessing Value is the silent wrong answer above.
File
<input type="file">. A browser will not let a page set a file input’s value — a
deliberate restriction, because a page that could would be a page that can read any file on
your disk by naming it. So a bind here writes nothing, silently, forever.
SelectMultiple
<select multiple>. Its value is the LIST of chosen options, so writing one text into it
selects at most one and reading it back returns at most one — a visitor’s other selections
vanish with no error anywhere.
Implementations§
Source§impl BoundInput
impl BoundInput
Sourcepub const UNKNOWN_REFUSAL: &'static str = "a `bind` sits on an element whose `type` is computed, so whether it binds a value or a \
checkbox's checked state cannot be known until the page runs. Write the type literally \
(`type=\"checkbox\"` or `type=\"text\"`), or use two elements"
pub const UNKNOWN_REFUSAL: &'static str = "a `bind` sits on an element whose `type` is computed, so whether it binds a value or a \ checkbox's checked state cannot be known until the page runs. Write the type literally \ (`type=\"checkbox\"` or `type=\"text\"`), or use two elements"
Why a BoundInput::Unknown binding is refused — held here, in ONE place, so the checker
and the lowering refuse it in the same words. Two refusals of the same thing in different
words send whoever reads one message searching for the other.
Sourcepub fn writes_checked(self) -> bool
pub fn writes_checked(self) -> bool
Whether this binding writes the checked PROPERTY rather than value.
Sourcepub fn refusal(self) -> Option<&'static str>
pub fn refusal(self) -> Option<&'static str>
Why this binding cannot be lowered, or None when it can.
★ TOTAL, AND THAT IS THE POINT. A new variant does not compile until somebody decides
whether it lowers or is refused BY NAME — silently absent is not one of the options, which
is the discipline action_verb_tier_lock holds over every UiStmt. Two of these arms exist
because the question used to be asked of the ATTRIBUTES ALONE: with no tag to look at, a
file input and a multiple select both fell through to Value and got a text write that
does nothing, while the author was told their binding was understood.
Trait Implementations§
Source§impl Clone for BoundInput
impl Clone for BoundInput
Source§fn clone(&self) -> BoundInput
fn clone(&self) -> BoundInput
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoundInput
impl Debug for BoundInput
Source§impl PartialEq for BoundInput
impl PartialEq for BoundInput
impl Copy for BoundInput
impl Eq for BoundInput
impl StructuralPartialEq for BoundInput
Auto Trait Implementations§
impl Freeze for BoundInput
impl RefUnwindSafe for BoundInput
impl Send for BoundInput
impl Sync for BoundInput
impl Unpin for BoundInput
impl UnsafeUnpin for BoundInput
impl UnwindSafe for BoundInput
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.