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() -> FieldState
Sourcepub fn modified(self, against: Baseline) -> FieldState
pub fn modified(self, against: Baseline) -> FieldState
Modified against a baseline; resettable when the baseline is the default.
Sourcepub fn compare<T>(self, value: &T, saved: Option<&T>, default: &T) -> FieldStatewhere
T: PartialEq,
pub fn compare<T>(self, value: &T, saved: Option<&T>, default: &T) -> FieldStatewhere
T: PartialEq,
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) -> FieldState
Sourcepub fn invalid(self, message: impl Into<String>) -> FieldState
pub fn invalid(self, message: impl Into<String>) -> FieldState
Refused, with the message to show.
Sourcepub fn validated(self, message: Option<String>) -> FieldState
pub fn validated(self, message: Option<String>) -> FieldState
Refused when message is some (a validation’s result).
Sourcepub fn disabled(self, reason: impl Into<String>) -> FieldState
pub fn disabled(self, reason: impl Into<String>) -> FieldState
Disabled, with the reason given to the user and to agents.
pub fn read_only(self) -> FieldState
pub fn pending(self) -> FieldState
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 moreSource§impl Debug for FieldState
impl Debug for FieldState
Source§impl Default for FieldState
impl Default for FieldState
Source§fn default() -> FieldState
fn default() -> FieldState
Source§impl PartialEq for FieldState
impl PartialEq for FieldState
Source§impl Serialize for FieldState
impl Serialize for FieldState
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for FieldState
impl StructuralPartialEq for FieldState
Auto Trait Implementations§
impl Freeze for FieldState
impl RefUnwindSafe for FieldState
impl Send for FieldState
impl Sync for FieldState
impl Unpin for FieldState
impl UnsafeUnpin for FieldState
impl UnwindSafe for FieldState
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.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more