Skip to main content

FormScalar

Trait FormScalar 

Source
pub trait FormScalar: Sized {
    const INPUT_TYPE: &'static str = "text";

    // Required methods
    fn blank() -> Option<Self>;
    fn parse_form(value: &str) -> Result<Self, String>;
    fn to_form(&self) -> String;
}
Expand description

A type one form key reads and writes: String, every TypedValue type, and an Option of either.

The value the parse sees is trimmed and non-empty; an empty submission is the field’s blank answer instead (the blank a record form declares, else "" for String or None for an Option).

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.

Required Methods§

Source

fn blank() -> Option<Self>

The value an empty submission reads as, when the type has one.

Source

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

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

Source

fn to_form(&self) -> String

The form spelling of a stored value.

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§

fn blank() -> Option<Self>

Source§

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

Source§

fn to_form(&self) -> String

Source§

impl FormScalar for String

Source§

fn blank() -> Option<Self>

Source§

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

Source§

fn to_form(&self) -> String

Source§

impl<T: TypedValue> FormScalar for Option<T>

Source§

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

Source§

fn blank() -> Option<Self>

Source§

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

Source§

fn to_form(&self) -> String

Implementors§

Source§

impl<T: TypedValue> FormScalar for T

Source§

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