Skip to main content

FieldState

Struct FieldState 

Source
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: bool

Must be given.

§invalid: Option<String>

Refused, and why.

§disabled: Option<String>

Cannot be focused nor changed, and why (“Needs an open image”).

§read_only: bool

Can be focused, selected and copied, not changed.

§pending: bool

Being checked.

Implementations§

Source§

impl FieldState

Source

pub fn new() -> Self

Source

pub fn modified(self, against: Baseline) -> Self

Modified against a baseline; resettable when the baseline is the default.

Source

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.

Source

pub fn required(self) -> Self

Source

pub fn invalid(self, message: impl Into<String>) -> Self

Refused, with the message to show.

Source

pub fn validated(self, message: Option<String>) -> Self

Refused when message is some (a validation’s result).

Source

pub fn disabled(self, reason: impl Into<String>) -> Self

Disabled, with the reason given to the user and to agents.

Source

pub fn read_only(self) -> Self

Source

pub fn pending(self) -> Self

Source

pub fn disabled_reason(&self) -> Option<&str>

The disabled field’s reason.

Source

pub fn message(&self) -> Option<&str>

The invalid field’s message.

Source

pub fn is_disabled(&self) -> bool

Source

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.

Source

pub fn is_editable(&self) -> bool

Its value can be changed: neither disabled nor read-only.

Source

pub fn is_resettable(&self) -> bool

“Reset to default” is offered.

Source

pub fn has(&self, mark: Mark) -> bool

Whether the field has a mark.

Source

pub fn marks(&self) -> Vec<Mark>

The marks the field has, in order of precedence.

Source

pub fn edge(&self) -> Option<Mark>

The mark that colours the field’s edge: the first in order of precedence. A required field shows its marker beside the label, not on the edge, and a read-only one has no edge colour: both leave the edge to the others.

Source

pub fn is_plain(&self) -> bool

Nothing to show.

Source

pub fn describe(&self) -> Value

The state as agents read it: every mark, the reason and the message.

Trait Implementations§

Source§

impl Clone for FieldState

Source§

fn clone(&self) -> FieldState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FieldState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FieldState

Source§

fn default() -> FieldState

Returns the “default value” for a type. Read more
Source§

impl PartialEq for FieldState

Source§

fn eq(&self, other: &FieldState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for FieldState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for FieldState

Source§

impl StructuralPartialEq for FieldState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.