Skip to main content

FormScalar

Trait FormScalar 

Source
pub trait FormScalar: Sized {
    const INPUT_TYPE: &'static str = "text";
    const STEP: Option<&'static str> = None;
    const SORTABLE: bool = true;

    // Required methods
    fn parse_form(value: &str) -> Result<Self, Text>;
    fn to_form(&self) -> String;

    // Provided methods
    fn input_value(stored: &str, zone: &TimeZone) -> String { ... }
    fn form_value(posted: &str, zone: &TimeZone) -> String { ... }
    fn to_label(&self) -> Text { ... }
    fn color(&self) -> Option<Color> { ... }
    fn icon(&self) -> Option<IconData> { ... }
    fn order(&self, _other: &Self) -> Option<Ordering> { ... }
}
Expand description

A type one form key reads and writes: String, every TypedValue type, every enum deriving Options, and an Option of any of them.

The value the parse sees is trimmed and non-empty; an empty submission is the record-form field’s blank answer instead, and a field with none is required.

A text field binds a path of any FormScalar type (Field::text), and the form derives read and write every field that is not #[form(embed)] through it.

Provided Associated Constants§

Source

const INPUT_TYPE: &'static str = "text"

The type attribute of the text control that edits it.

Source

const STEP: Option<&'static str> = None

The control’s step attribute, when its input type takes one.

Source

const SORTABLE: bool = true

Whether the database orders the stored column as the values order: a TypedValue’s SORTABLE, and true for any other type.

Required Methods§

Source

fn parse_form(value: &str) -> Result<Self, Text>

Parse a trimmed, non-empty submission, or return the error message.

Source

fn to_form(&self) -> String

The form spelling of a stored value: a TypedValue’s form_spelling.

Provided Methods§

Source

fn input_value(stored: &str, zone: &TimeZone) -> String

The control’s value for a stored value’s form spelling, shown in the request’s time zone zone: a TypedValue’s input_value, and the spelling itself for any other type.

Source

fn form_value(posted: &str, zone: &TimeZone) -> String

The form spelling of what the control posted, read in the request’s time zone zone: a TypedValue’s form_value, and the posted text itself for any other type.

Source

fn to_label(&self) -> Text

What a column cell and a group header read: the form spelling, or an Options enum’s label.

Source

fn color(&self) -> Option<Color>

The color a badge shows the value in: an Options enum’s #[option(color = "…")], and None for any other type.

Source

fn icon(&self) -> Option<IconData>

The icon a column shows the value with: an Options enum’s #[option(icon = …)], and None for any other type.

Source

fn order(&self, _other: &Self) -> Option<Ordering>

How self orders against other for a text field’s min and max: a TypedValue’s order, and None for any other type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FormScalar for Option<String>

Source§

impl FormScalar for String

Source§

impl<T> FormScalar for Option<T>
where T: NullableScalar,

Source§

const INPUT_TYPE: &'static str = T::INPUT_TYPE

Source§

const STEP: Option<&'static str> = T::STEP

Source§

const SORTABLE: bool = T::SORTABLE

Source§

fn input_value(stored: &str, zone: &TimeZone) -> String

Source§

fn form_value(posted: &str, zone: &TimeZone) -> String

Source§

fn parse_form(value: &str) -> Result<Option<T>, Text>

Source§

fn to_form(&self) -> String

Source§

fn to_label(&self) -> Text

Source§

fn color(&self) -> Option<Color>

Source§

fn icon(&self) -> Option<IconData>

Source§

fn order(&self, other: &Option<T>) -> Option<Ordering>

Implementors§

Source§

impl<T> FormScalar for T
where T: TypedValue,

Source§

const INPUT_TYPE: &'static str = T::INPUT_TYPE

Source§

const STEP: Option<&'static str> = T::STEP

Source§

const SORTABLE: bool = T::SORTABLE