pub struct FieldState {
pub modified: Option<Modified>,
pub required: bool,
pub invalid: Option<String>,
pub disabled: Option<String>,
pub read_only: bool,
pub pending: bool,
}Expand description
A field’s state. The default is a plain field: editable, optional, valid, unchanged.
Fields§
§modified: Option<Modified>Differs from its saved or default value.
required: boolMust be given.
invalid: Option<String>Refused, and why.
disabled: Option<String>Cannot be focused nor changed, and why (“Needs an open image”).
read_only: boolCan be focused, selected and copied, not changed.
pending: boolBeing checked.
Implementations§
Source§impl FieldState
impl FieldState
pub fn new() -> Self
Sourcepub fn modified(self, against: Baseline) -> Self
pub fn modified(self, against: Baseline) -> Self
Modified against a baseline; resettable when the baseline is the default.
Sourcepub fn compare<T: PartialEq>(
self,
value: &T,
saved: Option<&T>,
default: &T,
) -> Self
pub fn compare<T: PartialEq>( self, value: &T, saved: Option<&T>, default: &T, ) -> Self
Modified or not, from a comparison: differs from saved (when
given) or else from default. Resettable when it differs from
the default.
pub fn required(self) -> Self
Sourcepub fn validated(self, message: Option<String>) -> Self
pub fn validated(self, message: Option<String>) -> Self
Refused when message is some (a validation’s result).
Sourcepub fn disabled(self, reason: impl Into<String>) -> Self
pub fn disabled(self, reason: impl Into<String>) -> Self
Disabled, with the reason given to the user and to agents.
pub fn read_only(self) -> Self
pub fn pending(self) -> Self
Sourcepub fn disabled_reason(&self) -> Option<&str>
pub fn disabled_reason(&self) -> Option<&str>
The disabled field’s reason.
pub fn is_disabled(&self) -> bool
Sourcepub fn is_focusable(&self) -> bool
pub fn is_focusable(&self) -> bool
It takes the keyboard focus (and has a place in the Tab order): everything but a disabled field. A read-only field does.
Sourcepub fn is_editable(&self) -> bool
pub fn is_editable(&self) -> bool
Its value can be changed: neither disabled nor read-only.
Sourcepub fn is_resettable(&self) -> bool
pub fn is_resettable(&self) -> bool
“Reset to default” is offered.
Trait Implementations§
Source§impl Clone for FieldState
impl Clone for FieldState
Source§fn clone(&self) -> FieldState
fn clone(&self) -> FieldState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more